From 0b9cdbd0dd33af48746de83c00785daa293db975 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 6 Jun 2020 11:14:24 -0700 Subject: 6493 - browse: '#'s inside lines aren't headings --- prototypes/browse/26-headers/main.mu | 2 +- prototypes/browse/27/README.md | 2 +- prototypes/browse/27/main.mu | 23 ++++++++++++++--------- prototypes/browse/test1.md | 2 ++ 4 files changed, 18 insertions(+), 11 deletions(-) (limited to 'prototypes') diff --git a/prototypes/browse/26-headers/main.mu b/prototypes/browse/26-headers/main.mu index 463b018f..4f6b53e3 100644 --- a/prototypes/browse/26-headers/main.mu +++ b/prototypes/browse/26-headers/main.mu @@ -83,7 +83,7 @@ $render-normal:flush-buffered-newline: { } ## end soft newline support - # if start of paragraph and c == '#', switch to header + # if c == '#', switch to header compare c, 0x23 # '#' { break-if-!= diff --git a/prototypes/browse/27/README.md b/prototypes/browse/27/README.md index 6abb7af9..09813c57 100644 --- a/prototypes/browse/27/README.md +++ b/prototypes/browse/27/README.md @@ -1 +1 @@ -Support headers. +Don't treat '#'s inside lines as headers. diff --git a/prototypes/browse/27/main.mu b/prototypes/browse/27/main.mu index c6272343..48664533 100644 --- a/prototypes/browse/27/main.mu +++ b/prototypes/browse/27/main.mu @@ -63,6 +63,20 @@ $render-normal:loop: { loop $render-normal:loop } } + # if start of paragraph and c == '#', switch to header + compare start-of-paragraph?, 0 + { + break-if-= + compare c, 0x23 # '#' + { + break-if-!= + render-header-line fs, state + newline-seen? <- copy 1 # true + loop $render-normal:loop + } + } + # c is not a newline + start-of-paragraph? <- copy 0 # false # if c is unprintable (particularly a '\r' CR), skip it compare c, 0x20 loop-if-< @@ -85,15 +99,6 @@ $render-normal:flush-buffered-newline: { } ## end soft newline support - # if start of paragraph and c == '#', switch to header - compare c, 0x23 # '#' - { - break-if-!= - render-header-line fs, state - newline-seen? <- copy 1 # true - loop $render-normal:loop - } - # if (c == '*') switch to bold compare c, 0x2a # '*' { diff --git a/prototypes/browse/test1.md b/prototypes/browse/test1.md index 850edc90..c639f8a3 100644 --- a/prototypes/browse/test1.md +++ b/prototypes/browse/test1.md @@ -10,6 +10,8 @@ ###### abc +abc # def + abc def -- cgit 1.4.1-2-gfad0