From 9d22f058b90e3459b2a96ca8b513b769d34fe286 Mon Sep 17 00:00:00 2001 From: Paul Ganssle Date: Fri, 6 Nov 2020 12:50:15 -0500 Subject: [PATCH] Add a mechanism to escape '+' fragments Prior to this change, it was not possible to start a line with `+` at all, which is particularly problematic when you have a diff in literal blocks. Possibly a better long-term fix for this problem would be to disable all pre-processing between triple-backticks, but the ability to escape `+` at the beginning of a line seems useful in itself and is much easier to implement. --- _layouts/reveal.html | 13 +++++++++++-- _posts/0000-01-03-fragments.md | 11 ++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/_layouts/reveal.html b/_layouts/reveal.html index c04a143..59dc54d 100644 --- a/_layouts/reveal.html +++ b/_layouts/reveal.html @@ -62,13 +62,22 @@ | replace:'','' %}{% - assign first_char = line | strip + assign first_char = line | slice: 0,1 +%}{% + assign first_two = line + | slice: 0,2 %}{% if first_char == '+' %}{% assign processed_line = processed_line - | replace_first: '+','+ ' + | replace_first: '+','' + | prepend: '+ ' +%}{% + elsif first_two == '\+' +%}{% + assign processed_line = processed_line + | replace_first: '\+', '+' %}{% endif %}{{ processed_line }}{% comment %}Following line break is important{% endcomment %} diff --git a/_posts/0000-01-03-fragments.md b/_posts/0000-01-03-fragments.md index cae288c..8b3ceda 100644 --- a/_posts/0000-01-03-fragments.md +++ b/_posts/0000-01-03-fragments.md @@ -8,4 +8,13 @@ It's also possible to do fragments. + Your fragment may contain the ‘+’ character + You can also indent fragments -You can use <fragment/> to step other content. \ No newline at end of file +You can use <fragment/> to step other content. + +-- + +To start a line with a literal `+`, use `\+`: + +```diff +-I am a grate speller +\+I am a great speller +```