Pogues icon indicating copy to clipboard operation
Pogues copied to clipboard

Rich text and markdown syntax documentation

Open ghost opened this issue 8 years ago • 2 comments

Rich text is represented in Pogues with markdown syntax. These elements are used:

  • _italic_
  • **bold\**
  • _**bold and italic**_
  • [links with an url and no title\](http://example.com)
  • [links with a title and a simple dot as url\](. "a message")

The last item ([links with a title and a simple dot as url](. "a message")) is an internal convention to represent contextual information intended to be rendered in the questionnaire as some text with some information attached (for instance, with a tooltip on mouseover).

Other elements of the markdown syntax are not handled by the component for rich text edition.

Markdown is used here to represent some structured text in the format expected by the Pogues model, i.e. a regular string. The purpose is to have a common representation between Pogues and the server, but not to offer a fully compliant markdown editor. Markdown won't be rendered as is, but will be further processed to generate the questionnaire.

Syntax details:

  • * and _ typed in by the user will be escaped with a backslash in the resulting string, i.e. '*' and '_';
  • line breaks will be represented by '\n\n';
  • multiple consecutive line breaks will introduce weird characters; for instance two consecutive line breaks will give '\n\n​\n\n'; in other words, '​\n\n' represent an empty line; as a convention, we could consider that, like in markdown, consecutive empty lines do not hold any information (i.e. two empty lines mean the same as one empty line).

ghost avatar Sep 06 '16 06:09 ghost

In the present workflow, the markdown handled by Pogues had been generated by Pogues (we do not import some questionnaires produced outside of Pogues). So there shouldn't be any issue with parsing Markdown in Pogues. But, for information, if it weren't the case there might be an issue with parsing some strings with white spaces before or after * and _ special characters (to experiment with it, you can try to type markdown directly in the generic input).

I could not find official information about how to parse that kind of strings, but most online parsers (gitHub issue editor for instance, or dillinger) will parse them in a different way that Pogues:

  • ** some bold text** will be rendered as some bold text by Pogues but as * some bold text* by these online editors (see raw markdown for this issue as a proof 😆 );
  • in the same way, **some bold text ** will be rendered by Pogues as some bold text instead of *some bold text * for gitHub or **some bold text ** for dillinger;
  • the same goes for the underscore sign.

ghost avatar Sep 06 '16 06:09 ghost

Don't know if this relevant in our current context ? @loichenninger

There's a question on how we parse Markdown in VTL strings (i'm thinking custom label here), but it might be decoupled for this issue.

romaintailhurat avatar Feb 16 '22 09:02 romaintailhurat