Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all inline elements to avoid wrong space breaking #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions markdown/display-xexpr.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,27 @@
(define escape-contents (curry escape #rx"[<>&]"))

(define (newline-and-indent? tag)
(not (memq tag '(a code em img span strong sup))))
;; from https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
(not (memq tag '(a abbr acronym audio
b bdi bdo big br button
canvas cite code
data datalist del dfn
em embed
i iframe img input ins
kbd
label
map mark meter
noscript
object output
picture progress
q
ruby
s samp script select slot small span strong sub sup svg
template textarea time
u
tt
var video
wbr))))

(define (void-element? tag)
;; Note: I'm not using Racket xml collection's
Expand Down Expand Up @@ -96,6 +116,6 @@
;; Ampersand should NOT be escaped in <script> or <style>, because
;; HTML5 defines these as raw text elements.
(check-equal? (xexpr->string '(script () "a;\nb;\n1 & 2;\n"))
"\n<script>a;\nb;\n1 & 2;\n</script>")
"<script>a;\nb;\n1 & 2;\n</script>")
(check-equal? (xexpr->string '(style () "a;\nb;\n1 & 2;\n"))
"\n<style>a;\nb;\n1 & 2;\n</style>"))
8 changes: 1 addition & 7 deletions markdown/test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ <h1 id="heading-level-1">Heading level 1</h1>
<h2 id="heading-level-2">Heading level 2</h2>
<p>Some normal text.</p>
<p>Here is some word-level formatting. Also, this uses two spaces before newline to ensure hard line breaks:</p>
<p><em>Italic</em>.
<br /><em>Italic</em>.
<br /><strong>Bold</strong>.
<br /><strong>Bold</strong>.
<br /><strong>Bold with <em>italic</em> inside it</strong>.
<br /><em>Italic with <strong>bold</strong> inside it</em>.
<br /><code>I am code</code>.</p>
<p><em>Italic</em>.<br /><em>Italic</em>.<br /><strong>Bold</strong>.<br /><strong>Bold</strong>.<br /><strong>Bold with <em>italic</em> inside it</strong>.<br /><em>Italic with <strong>bold</strong> inside it</em>.<br /><code>I am code</code>.</p>
<p>I am <em>italic phrase on one line</em>.</p>
<p>I am <em>italic phrase wrapped across two lines in the Mardkdown source</em>, did that work?</p>
<p>This is _surrounded by literal underlines_ and this is *surrounded by literal asterisks*.</p>
Expand Down