Markdown: multiple improvements and fixes
ClosedPublic

Authored by nibags on Aug 23 2019, 8:18 AM.

Details

Summary

Improve & fix detection of bold/italic text

BUG: 390309

In bold and italic text highlighting, underscores and asterics aren't allowed inside, for example **some_text** isn't highlighted correctly. I have improved regex to detect bold and italic text: now asterisks, underscores and escapes are allowed inside.

Improve fenced code blocks

The way to write fenced code blocks varies depending on the Markdown/MultiMarkdown implementation. Some support only 3 backticks, others more than 3 backticks, others both; and others 3 tildes (~). [1]

Therefore, I think it's a good idea to support all implementations: code blocks can be written with 3 backticks or more, or with 3 tildes or more . Other editors, such as Visutal Studio Code, Atom and Sublime Text highlight fenced code blocks in this way.
Unfortunately, this is only possible using dynamic rules with several RegExpr, which isn't very optimal. I have no problem modifying that if you don't like it.

Also:

  • Add folding in fenced code blocks.
  • Add more keywords to identify languages.
  • Add to highlight in fenced code blocks the languages that are already loaded by default, since they are included via IncludeRules (JavaScript, TypeScript, JSX, SQL, Mustache/Handlebars, reST & Doxygen).
  • Add more languages in the code blocks. Some of the most popular languages are included [3] [4]: C, Go, Java, JavaScript, TypeScript, Matlab, Perl, R & Ruby.

Improve code blocks

  • Highlight single code with more than one backticks. [2]
  • Fix: highlight indented code only after an empty line.

Improve highlighting of links and references

Improve metadata highlighting

Previously, some metadata Keys were highlighted anywhere in the document. Now the metadata is highlighted only on the first line of the Markdown document. [6] [7]

Improves list detection

Through dynamic rules, the indentation of lists is captured, in order to correctly highlight the indented content in them.
Now the text within the lists is highlighted using "dsNormal", so as not to saturate Markdown documents with many colors.

Add support of inline HTML

IncludeRules is used to highlight only HTML tags. [8]

Others

  • Highlight checkboxs in lists.
  • Add escape characters [5].
  • Add ##Alerts and ##Modelines in the comments.
  • Some minor improvements, such as replacing some RegExpr rules and adding column="0" in some rules.

Sources:

Diff Detail

Repository
R216 Syntax Highlighting
Branch
improve-markdown
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 15521
Build 15539: arc lint + arc unit
nibags created this revision.Aug 23 2019, 8:18 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptAug 23 2019, 8:18 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Aug 23 2019, 8:18 AM
nibags edited the summary of this revision. (Show Details)Aug 23 2019, 8:37 AM
nibags added reviewers: cullmann, dhaumann.
dhaumann accepted this revision.Aug 23 2019, 2:08 PM

Thanks for the very detailed description in the review request, very much appreciated. The improvements are numerous, therefore please commit.

This revision is now accepted and ready to land.Aug 23 2019, 2:08 PM
nibags updated this revision to Diff 64463.Aug 24 2019, 9:05 AM
  • Fix bug in blockquotes and improve integration with R Markdown
nibags closed this revision.Aug 24 2019, 9:45 AM