From 74a1321f619bb7962c3e36c2071406fe85625dbc Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Mon, 7 Jan 2019 22:30:48 -0500 Subject: [PATCH] Don't allow URLs to be hyphenated --- lib/ronn/roff.rb | 4 ++-- test/markdown_syntax.roff | 12 ++++++------ test/section_reference_links.roff | 2 +- test/url_formatting.ronn | 3 +++ 4 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 test/url_formatting.ronn diff --git a/lib/ronn/roff.rb b/lib/ronn/roff.rb index 5425ca8..f008f67 100644 --- a/lib/ronn/roff.rb +++ b/lib/ronn/roff.rb @@ -277,13 +277,13 @@ def inline_filter(node) inline_filter(node.children) elsif node.has_attribute?('data-bare-link') write '\fI' - inline_filter(node.children) + write '\%' + escape(node.attributes['href'].content) write '\fR' else inline_filter(node.children) write ' ' write '\fI' - write escape(node.attributes['href'].content) + write '\%' + escape(node.attributes['href'].content) write '\fR' end diff --git a/test/markdown_syntax.roff b/test/markdown_syntax.roff index 96fe57b..8ec6576 100644 --- a/test/markdown_syntax.roff +++ b/test/markdown_syntax.roff @@ -37,7 +37,7 @@ Inline markup like _italics_, **bold**, and `code()`\. .SS "Philosophy" Markdown is intended to be as easy\-to\-read and easy\-to\-write as is feasible\. .P -Readability, however, is emphasized above all else\. A Markdown\-formatted document should be publishable as\-is, as plain text, without looking like it\'s been marked up with tags or formatting instructions\. While Markdown\'s syntax has been influenced by several existing text\-to\-HTML filters \-\- including Setext \fIhttp://docutils\.sourceforge\.net/mirror/setext\.html\fR, atx \fIhttp://www\.aaronsw\.com/2002/atx/\fR, Textile \fIhttp://textism\.com/tools/textile/\fR, reStructuredText \fIhttp://docutils\.sourceforge\.net/rst\.html\fR, Grutatext \fIhttp://www\.triptico\.com/software/grutatxt\.html\fR, and EtText \fIhttp://ettext\.taint\.org/doc/\fR \-\- the single biggest source of inspiration for Markdown\'s syntax is the format of plain text email\. +Readability, however, is emphasized above all else\. A Markdown\-formatted document should be publishable as\-is, as plain text, without looking like it\'s been marked up with tags or formatting instructions\. While Markdown\'s syntax has been influenced by several existing text\-to\-HTML filters \-\- including Setext \fI\%http://docutils\.sourceforge\.net/mirror/setext\.html\fR, atx \fI\%http://www\.aaronsw\.com/2002/atx/\fR, Textile \fI\%http://textism\.com/tools/textile/\fR, reStructuredText \fI\%http://docutils\.sourceforge\.net/rst\.html\fR, Grutatext \fI\%http://www\.triptico\.com/software/grutatxt\.html\fR, and EtText \fI\%http://ettext\.taint\.org/doc/\fR \-\- the single biggest source of inspiration for Markdown\'s syntax is the format of plain text email\. .P To this end, Markdown\'s syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean\. E\.g\., asterisks around a word actually look like *emphasis*\. Markdown lists look like, well, lists\. Even blockquotes look like quoted passages of text, assuming you\'ve ever used email\. .SS "Inline HTML" @@ -111,7 +111,7 @@ AT&T .fi .IP "" 0 .P -Similarly, because Markdown supports \fIinline HTML\fR, if you use angle brackets as delimiters for HTML tags, Markdown will treat them as such\. But if you write: +Similarly, because Markdown supports \fI\%#html\fR, if you use angle brackets as delimiters for HTML tags, Markdown will treat them as such\. But if you write: .IP "" 4 .nf 4 < 5 @@ -134,9 +134,9 @@ The implication of the "one or more consecutive lines of text" rule is that Mark .P When you \fIdo\fR want to insert a \fB
\fR break tag using Markdown, you end a line with two or more spaces, then type return\. .P -Yes, this takes a tad more effort to create a \fB
\fR, but a simplistic "every line break is a \fB
\fR" rule wouldn\'t work for Markdown\. Markdown\'s email\-style \fIblockquoting\fR and multi\-paragraph \fIlist items\fR work best \-\- and look better \-\- when you format them with hard breaks\. +Yes, this takes a tad more effort to create a \fB
\fR, but a simplistic "every line break is a \fB
\fR" rule wouldn\'t work for Markdown\. Markdown\'s email\-style \fI\%#blockquote\fR and multi\-paragraph \fI\%#list\fR work best \-\- and look better \-\- when you format them with hard breaks\. .SS "Headers" -Markdown supports two styles of headers, Setext \fIhttp://docutils\.sourceforge\.net/mirror/setext\.html\fR and atx \fIhttp://www\.aaronsw\.com/2002/atx/\fR\. +Markdown supports two styles of headers, Setext \fI\%http://docutils\.sourceforge\.net/mirror/setext\.html\fR and atx \fI\%http://www\.aaronsw\.com/2002/atx/\fR\. .P Setext\-style headers are "underlined" using equal signs (for first\-level headers) and dashes (for second\-level headers)\. For example: .IP "" 4 @@ -900,8 +900,8 @@ _ underscore .SH "AUTHOR" Markdown was created by John Gruber\. .P -Manual page by Ryan Tomayko\. It\'s pretty much a direct copy of the Markdown Syntax Reference \fIhttp://daringfireball\.net/projects/markdown/syntax\fR, also by John Gruber\. +Manual page by Ryan Tomayko\. It\'s pretty much a direct copy of the Markdown Syntax Reference \fI\%http://daringfireball\.net/projects/markdown/syntax\fR, also by John Gruber\. .SH "SEE ALSO" ronn(5) .br -\fIhttp://daringfireball\.net/projects/markdown/\fR +\fI\%http://daringfireball\.net/projects/markdown/\fR diff --git a/test/section_reference_links.roff b/test/section_reference_links.roff index 243c93a..2f1222b 100644 --- a/test/section_reference_links.roff +++ b/test/section_reference_links.roff @@ -4,4 +4,4 @@ .SH "SECTION 1" See the following section\. .SH "SECTION 2" -See \fISECTION 1\fR or \fIto put it another way\fR or even \fIlike this\fR +See \fI\%#SECTION\-1\fR or \fI\%#SECTION\-1\fR or even \fI\%#SECTION\-1\fR diff --git a/test/url_formatting.ronn b/test/url_formatting.ronn new file mode 100644 index 0000000..6b029d6 --- /dev/null +++ b/test/url_formatting.ronn @@ -0,0 +1,3 @@ +# URL formatting + +Documentation of the Emily programming language can be found at or . \ No newline at end of file