Skip to content

Resolve "Custom renderers cleanup - erb"

Derek Knox requested to merge 232567-templater into master

What does this MR do?

It pre-processes a file's source prior to feeding it to the downstream editor, Toast UI currently. This enables us to pre-flag (via codeblock triple-tick syntax) template syntaxes (currently ERB, but this can be extended/abstracted to facilitate other templating syntaxes) such that Toast UI doesn't process the code as content. Without an approach like this, templated code within a file gets interpreted as raw content (paragraphs most commonly) and thus is susceptible to important spacing, indentation, and character escaping information. This pre-processing approach has the side-effect benefit of the templated code to be editable via Toast UI's internal code editor.

There are still exception cases to handle with this approach, but it is much cleaner and less complex than our previous custom renderer approaches. These exceptions will be handled in follow-ups and are:

  • ignore when code templates are already in a codeblock or inline code
  • account for code template scenarios nested inline of content. Previously we used render_embedded_ruby_text.js and we may still use it for these cases however it isn't full proof as Toast UI interprets it as content and is thus susceptible to the aforementioned spacing, indentation, and character escaping degredation.

Screenshots

source before after
Screen_Shot_2020-08-05_at_6.13.50_AM Screen_Shot_2020-08-05_at_6.14.24_AM Screen_Shot_2020-08-05_at_6.13.54_AM

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

Closes #232567 (closed)

Edited by Derek Knox

Merge request reports

Loading