Labels in markdown done
This MR is a part of issue #87.
What's changed:
- Added
MarkdownDecorator
interface for decorating markdown nodes with our custom delimiters to process them later. - Added
ExtensionProcessor
interface. You can override it to process your own type of Markdown extension. All processors are defined insideMarkDownConverterProvider
as arguments toGitlabExtensionsDelimiterProcessor
- There are also
CompositeMarkdownDecorator
andCompositeVisitor
which are already used to propagate our custom decorators and visitors to parser. -
MarkdownConverterProvider
now needs list of available labels to process Markdown. - To make usage of
MarkdownConverterProvider
more convenient now there is aProjectMarkdownConverterProvider
which downloads labels for project automatically. - Labels are cached inside
LabelInteractor
for current session. It is made to prevent a lot of requests for labels (for lists, for example).
To be able to parse nodes where first-only delimiter is existent, we are decorating each of such nodes with out custom project-specific extension syntax.
Extension syntax looks like this: %%%%%${EXTENSION_TYPE}_${EXTENSION_ARGUMENTS}%%%%%
For example:
We have label ~single
defined in markdown.
We are making custom LabelDecorator that replaces such nodes to our custom extension:
%%%%%LABEL_SINGLE_single%%%%%
In this case out LABEL extension provides its own arguments string which have its own syntax:
SINGLE_single
where SINGLE
is node type (nodes can be single-word, multi-word and id-based) and single
is node name.
After decorating, markdown parser can detect our custom nodes using delimiters %%%%%
and launches our GitlabExtensionsDelimiterProcessor
It is detecting type of extension based on substring before the first _
symbol and decides which extension processor to launch, and propagates arguments to it.
Custom extension processor converts current Text
node to its own type.
After all, our custom nodes can be processed using Visitor. Visitors are also defined inside MarkdownConverterProvider
.
What's not done:
- Click handling on labels. Now click leads to log record "Label ${name} clicked"
- Spannable cannot set margins in text. It means that we maybe need to control line-height of target
TextView
to make labels not to meld if they are under each other in separate lines:
Here's a result of this merge request: