Skip to content

Render markdown attribute definitions as tooltips

Enrique Alcántara requested to merge render-attribute-definitions into master

What does this MR do?

Background

Attribute definitions are a way of adding metadata to markdown elements like headings and lists. For example, if we want to add some class selectors to a heading, we can do the following:

## On this page
{:.no_toc .hidden-md .hidden-lg}

When converting this piece of Markdown to HTML, if the renderer supports attribute definitions, it will output this:

<h2 class="no_toc hidden-md hidden-lg">On this page</h2>

Attribute definitions are not part of the CommonMark or GFM specifications. As a result, the Static Site Editor’s WYSIWYG editor, Toast UI, does not know how to convert them to HTML. Initially, we wrote a custom renderer to render these attribute definitions as read-only snippets in the editor:

image

The problem with this approach is that when Toast UI converts the HTML in WYSIWYG mode to Markdown, it interprets this attribute definitions as entities that are independent from the elements they decorate. As a result, the code snippet above is transformed to:

## On this page

{:.no_toc .hidden-md .hidden-lg}

What are these changes about?

These changes make the WYSIWYG editor treat attribute definitions as metadata for an element instead of independent entities. It does that by:

  • Not displaying attribute definitions as independent paragraphs.
  • Attaching attribute definitions to their related elements when converting Markdown to HTML.
  • Displaying attribute definitions as tooltips in their related elements.

Screenshots

Screen_Shot_2020-08-26_at_3.05.37_PM

Screen_Shot_2020-08-26_at_3.05.29_PM

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Enrique Alcántara

Merge request reports

Loading