From 3188b0b9fa8a61c707b9d40ae70eb152d8d0e74c Mon Sep 17 00:00:00 2001 From: ivanspengen Date: Tue, 10 Apr 2018 09:22:02 +0200 Subject: [PATCH] Fixed code block multiline encoding on quotes/span --- tests/test_github_issues.py | 34 ++++++++++++++++++++++++++++++++++ textile/core.py | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 27befff7..6b5b3d75 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -262,3 +262,37 @@ def test_issue_56(): result = textile.textile("- :=\n-") expect = '
\n
' assert result == expect + +def test_github_issue_57(): + input = '''bc.. This is some TEXT inside a "Code BLOCK" + +{ + if (JSON) { + + return {"JSON":"value"} + } +} + +Back to 10-4 CAPS + +p.. Some multiline Paragragh + +Here is some output!!! "Some" CAPS''' + + expect = '''
This is some TEXT inside a "Code BLOCK"
+
+{
+  if (JSON) {
+
+    return {"JSON":"value"}
+  }
+}
+
+Back to 10-4 CAPS 
+ +

Some multiline Paragragh + +Here is some output!!! “Some” CAPS

''' + t = textile.Textile() + result = t.parse(input) + assert result == expect diff --git a/textile/core.py b/textile/core.py index 7572a468..a5dae835 100644 --- a/textile/core.py +++ b/textile/core.py @@ -503,7 +503,7 @@ def block(self, text): block.outer_atts) line = "\t{0}".format(line) else: - if block.tag == 'pre': + if block.tag == 'pre' or block.inner_tag == 'code': line = self.shelve(encode_html(line, quotes=True)) else: line = self.graf(line)