You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2016/01/06 18:06:25 UTC

[1/4] allura git commit: [#7987] ticket:882 Remove deprecated FencedCodeProcessor, change user docs

Repository: allura
Updated Branches:
  refs/heads/master 19c532faa -> dfa249a65


[#7987] ticket:882 Remove deprecated FencedCodeProcessor, change user docs


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/307f45b4
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/307f45b4
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/307f45b4

Branch: refs/heads/master
Commit: 307f45b47a57a5e4ebcf31b43e414c1183594354
Parents: b8712c0
Author: Denis Kotov <de...@gmail.com>
Authored: Mon Dec 28 12:13:34 2015 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Jan 6 12:06:03 2016 -0500

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py              |  2 +-
 Allura/allura/lib/markdown_extensions.py      | 19 -------------------
 Allura/allura/templates/jinja_master/lib.html |  2 ++
 3 files changed, 3 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/307f45b4/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index f7392cd..7e8e5db 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -439,7 +439,7 @@ class Globals(object):
         '''return a markdown.Markdown object on which you can call convert'''
         return ForgeMarkdown(
             # 'fenced_code'
-            extensions=['codehilite',
+            extensions=['fenced_code', 'codehilite',
                         ForgeExtension(
                             **kwargs), 'tables', 'toc', 'nl2br'],
             output_format='html4')

http://git-wip-us.apache.org/repos/asf/allura/blob/307f45b4/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 016c5e4..c292d66 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -21,7 +21,6 @@ from urlparse import urljoin
 
 from tg import config
 from bs4 import BeautifulSoup
-from markdown.extensions.fenced_code import FencedBlockPreprocessor
 import html5lib
 import html5lib.serializer
 import html5lib.filters.alphabeticalattributes
@@ -249,7 +248,6 @@ class ForgeExtension(markdown.Extension):
         # allow markdown within e.g. <div markdown>...</div>  More info at:
         # https://github.com/waylan/Python-Markdown/issues/52
         md.preprocessors['html_block'].markdown_in_raw = True
-        md.preprocessors['fenced-code'] = FencedBlockPreprocessor(md)
         md.preprocessors.add('plain_text_block', PlainTextPreprocessor(md), "_begin")
         md.preprocessors.add('macro_include', ForgeMacroIncludePreprocessor(md), '_end')
         # this has to be before the 'escape' processor, otherwise weird
@@ -376,23 +374,6 @@ class PlainTextPreprocessor(markdown.preprocessors.Preprocessor):
         return txt
 
 
-class FencedCodeProcessor(markdown.preprocessors.Preprocessor):
-    pattern = '~~~~'
-
-    def run(self, lines):
-        in_block = False
-        new_lines = []
-        for line in lines:
-            if line.lstrip().startswith(self.pattern):
-                in_block = not in_block
-                continue
-            if in_block:
-                new_lines.append('    ' + line)
-            else:
-                new_lines.append(line)
-        return new_lines
-
-
 class ForgeMacroPattern(markdown.inlinepatterns.Pattern):
 
     def __init__(self, *args, **kwargs):

http://git-wip-us.apache.org/repos/asf/allura/blob/307f45b4/Allura/allura/templates/jinja_master/lib.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index b3626e9..b913f41 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -731,6 +731,8 @@ allowed, permitting basic styling and layout: &lt;div markdown style="float:left
 ~~~~~~''')}}
 </div>
 
+<p><a href="https://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html">Fenced Code Blocks syntax is also supported</a> </p>
+
 
 <div class="markdown_syntax_section hidden_in_modal md_ex_includes{{id}}">
 <h2 id="md_ex_includes{{id}}">Includes</h2>


[4/4] allura git commit: [#7987] further improve code highlighting markdown docs

Posted by br...@apache.org.
[#7987] further improve code highlighting markdown docs


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/dfa249a6
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/dfa249a6
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/dfa249a6

Branch: refs/heads/master
Commit: dfa249a652851cf9859b29117b6ff5b0b6e569d7
Parents: aebcfc5
Author: Dave Brondsema <da...@brondsema.net>
Authored: Wed Jan 6 11:48:19 2016 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Jan 6 12:06:04 2016 -0500

----------------------------------------------------------------------
 Allura/allura/templates/jinja_master/lib.html | 52 +++++++++++++---------
 1 file changed, 31 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/dfa249a6/Allura/allura/templates/jinja_master/lib.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index 865807f..ad4e227 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -407,9 +407,10 @@ paragraph.""")}}
 <h2 id="md_ex_pre{{id}}">Preformatted Text</h2>
 <p>If you want some text to show up exactly as you write it, without
 Markdown doing anything to it, just indent every line by at least 4
-spaces (or 1 tab).  As an alternative to indenting, you can use 4 or
-more tildes before and after the text.  See examples in the
-<a href="#md_ex_code">Code Highlighting section</a>
+spaces (or 1 tab).  As an alternative to indenting, you can make a code block use 3 or
+more tildes (~) or backticks (`) on a line before and after the text
+(<a href="https://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html">syntax details</a>). See examples in the
+<a href="#md_ex_code">Code Highlighting section</a>.
 </p>
 <div class="codehilite"><pre>
     This line won't *have any markdown* formatting applied.
@@ -690,49 +691,58 @@ allowed, permitting basic styling and layout: &lt;div markdown style="float:left
 
 <div class="markdown_syntax_section hidden_in_modal md_ex_code{{id}}">
 <h2 id="md_ex_code{{id}}">Code Highlighting</h2>
-<p>The code highlighting syntax uses <a href="http://pythonhosted.org/Markdown/extensions/code_hilite.html">CodeHilite</a> and is colored with <a href="http://pygments.org/">Pygments</a>. It follows the same syntax as regular Markdown code blocks, except that there are two ways to tell the highlighter what language to use for the code block.</p>
+<p>The code highlighting syntax uses <a href="http://pythonhosted.org/Markdown/extensions/code_hilite.html">CodeHilite</a> and is colored with <a href="http://pygments.org/">Pygments</a>. It follows the same syntax as regular Markdown <a href="#md_ex_pre">code blocks</a>, with ways to tell the highlighter what language to use for the code block.</p>
 
-<p>Fenced Code Blocks <a href="https://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html">syntax</a> is also supported.</p>
-
-<p>If the first line of the codeblock contains a shebang, the language is derived from that and line numbers are used.</p>
+<p>The language will be detected automatically, if possible.  Or you can specify it on the first line with 3 colons and the language name.</p>
 
 <div class="codehilite"><pre>
-    #!/usr/bin/python
-    # Code goes here ...
+    :::python
+    import abc
 </pre></div>
 
 <p>Output:</p>
 {{g.markdown.convert('''
-    #!/usr/bin/python
-    # Code goes here ...''')}}
+    :::python
+    import abc''')}}
 
-<p>If the first line contains a shebang, but the shebang line does not contain a path (a single / or even a space) or If the first line begins with three or more colons, the text following the colons identifies the language. In both cases, the first line is removed from the code block before processing.</p>
+<p>If the first line of the codeblock contains a shebang, the language is derived from that and line numbers are used.
+If shebang line contains a full path, it will be included in the output.  If it does not contain a path (a single / or even a space),
+then that shebang line will be omitted from output.
+</p>
 
 <div class="codehilite"><pre>
-    :::python
-    # Code goes here ...
+    #!/usr/bin/python
+    import abc
 </pre></div>
 
 <p>Output:</p>
 {{g.markdown.convert('''
-    :::python
-    # Code goes here ...''')}}
+    #!/usr/bin/python
+    import abc''')}}
 
-<p>You can also designate a code block by surrounding it with lines of tildes. The type of code highlighting to apply will be inferred based on the code within, or you can specify like above.</p>
+<p>If using a code block of tildes or backticks, you can also specify the language on the first divider line</p>
 
 <div class="codehilite"><pre>
-~~~~~~
+~~~html
 &lt;a href="#">My code&lt;/a>
-~~~~~~
+~~~
+</pre></div>
+
+<div class="codehilite"><pre>
+```html
+&lt;a href="#">My code&lt;/a>
+```
 </pre></div>
 
 <p>Output:</p>
 {{g.markdown.convert('''
-~~~~~~
+```html
 <a href="#">My code</a>
-~~~~~~''')}}
+```''')}}
 </div>
 
+<p>Many languages are supported.  See all the "short names" listed in the <a href="http://pygments.org/docs/lexers/">Pygments docs</a>.</p>
+
 
 <div class="markdown_syntax_section hidden_in_modal md_ex_includes{{id}}">
 <h2 id="md_ex_includes{{id}}">Includes</h2>


[2/4] allura git commit: [#7987] ticket:882 uset FencedCodeProcessor for fence code

Posted by br...@apache.org.
[#7987] ticket:882 uset FencedCodeProcessor for fence code


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b8712c0c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b8712c0c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b8712c0c

Branch: refs/heads/master
Commit: b8712c0c0fe237bf2d3841630e557efb57868c75
Parents: 19c532f
Author: Denis Kotov <de...@gmail.com>
Authored: Fri Dec 25 21:22:34 2015 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Jan 6 12:06:03 2016 -0500

----------------------------------------------------------------------
 Allura/allura/lib/markdown_extensions.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b8712c0c/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index cbccf5d..016c5e4 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -21,6 +21,7 @@ from urlparse import urljoin
 
 from tg import config
 from bs4 import BeautifulSoup
+from markdown.extensions.fenced_code import FencedBlockPreprocessor
 import html5lib
 import html5lib.serializer
 import html5lib.filters.alphabeticalattributes
@@ -248,7 +249,7 @@ class ForgeExtension(markdown.Extension):
         # allow markdown within e.g. <div markdown>...</div>  More info at:
         # https://github.com/waylan/Python-Markdown/issues/52
         md.preprocessors['html_block'].markdown_in_raw = True
-        md.preprocessors['fenced-code'] = FencedCodeProcessor()
+        md.preprocessors['fenced-code'] = FencedBlockPreprocessor(md)
         md.preprocessors.add('plain_text_block', PlainTextPreprocessor(md), "_begin")
         md.preprocessors.add('macro_include', ForgeMacroIncludePreprocessor(md), '_end')
         # this has to be before the 'escape' processor, otherwise weird


[3/4] allura git commit: [#7987] ticket:882 Move docs changes to appropriate section

Posted by br...@apache.org.
[#7987] ticket:882 Move docs changes to appropriate section


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/aebcfc55
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/aebcfc55
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/aebcfc55

Branch: refs/heads/master
Commit: aebcfc555f3d3fb53f9a30de0bbe9f9966bcc5e4
Parents: 307f45b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Jan 5 16:28:43 2016 +0200
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Jan 6 12:06:04 2016 -0500

----------------------------------------------------------------------
 Allura/allura/templates/jinja_master/lib.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/aebcfc55/Allura/allura/templates/jinja_master/lib.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index b913f41..865807f 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -692,6 +692,8 @@ allowed, permitting basic styling and layout: &lt;div markdown style="float:left
 <h2 id="md_ex_code{{id}}">Code Highlighting</h2>
 <p>The code highlighting syntax uses <a href="http://pythonhosted.org/Markdown/extensions/code_hilite.html">CodeHilite</a> and is colored with <a href="http://pygments.org/">Pygments</a>. It follows the same syntax as regular Markdown code blocks, except that there are two ways to tell the highlighter what language to use for the code block.</p>
 
+<p>Fenced Code Blocks <a href="https://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html">syntax</a> is also supported.</p>
+
 <p>If the first line of the codeblock contains a shebang, the language is derived from that and line numbers are used.</p>
 
 <div class="codehilite"><pre>
@@ -731,8 +733,6 @@ allowed, permitting basic styling and layout: &lt;div markdown style="float:left
 ~~~~~~''')}}
 </div>
 
-<p><a href="https://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html">Fenced Code Blocks syntax is also supported</a> </p>
-
 
 <div class="markdown_syntax_section hidden_in_modal md_ex_includes{{id}}">
 <h2 id="md_ex_includes{{id}}">Includes</h2>