src/post2html: Ability to reference content of previous fence
I'll be using this to show example HTML code and then output it as actual HTML to be rendered as part of the article. Otherwise the HMTL has to be duplicated and maintained in multiple places. An alternative is to include a file, but that is much less convenient for smaller snippets.master
parent
b3ad4f7599
commit
61b80c516f
|
@ -109,6 +109,15 @@ prefmt()
|
|||
next
|
||||
}
|
||||
|
||||
# reference to the content of the last fence (e.g. if a previous
|
||||
# code block is HTML and we want to render it as an example)
|
||||
/^```/ {
|
||||
gather = !gather
|
||||
if ( gather ) gblock = ""
|
||||
}
|
||||
!/^```/ && gather { gblock = gblock $0 "\n" }
|
||||
!gather && /^ *@LASTFENCE@$/ { print gblock; next }
|
||||
|
||||
{ print }
|
||||
'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue