Add underline command in markdown

This commit is contained in:
Gregory Soutade 2014-03-27 18:25:36 +01:00
parent 4bd583f92f
commit 577acbd9f5
6 changed files with 30 additions and 13 deletions

View File

@ -18,4 +18,4 @@
along with Dynastie. If not, see <http://www.gnu.org/licenses/>.
"""
__all__ = ["generator", "index", "post", "category", "tag", "archive", "rss", "atom", "all_posts"]
__all__ = ["generator", "index", "post", "category", "tag", "archive", "rss", "atom", "all_posts", "ljdc"]

View File

@ -205,15 +205,20 @@ class DynastieGenerator:
return root
filename = base.getAttribute('file')
if not base.hasAttribute('block'):
self.addError('No \'block\' attribute defined')
return root
target_block = base.getAttribute('block')
if not os.path.exists(src + '/' + filename):
self.addError('Base ' + filename + ' doesn\'t exists')
return root
target_blocks = base.getElementsByTagNameNS(self.URI, 'block')
if len(target_blocks) == 0:
self.addError('No \'block\' defined in ' + src + '/' + filename)
return root
for target_block in target_blocks:
if not target_block.hasAttribute('name'):
self.addError('Every block must have a name in ' + src + '/' + filename)
return root
dom2 = root
try:
dom2 = parse(src + '/' + filename)
@ -225,19 +230,22 @@ class DynastieGenerator:
block_found = False
for block in blocks:
if not block.hasAttribute('name'):
self.addError('block has no attribute \'name\' in ' + filename)
self.addError('block has no attribute \'name\' in ' + src + '/' + filename)
return root
blockname = block.getAttribute('name')
if blockname != target_block:
continue
for target_block in target_blocks:
if blockname != target_block.getAttribute('name'):
continue
for child in root.childNodes:
block.parentNode.appendChild(child.cloneNode(True))
for child in target_block.childNodes:
block.parentNode.appendChild(child.cloneNode(True))
block_found = True
break
block.parentNode.removeChild(block)
block_found = True
if not block_found:
self.addError('Block ' + target_block + ' not found in ' + src + '/' + filename)
self.addError('Any block found in ' + src + '/' + filename)
return root
root = dom2.firstChild

View File

@ -1614,16 +1614,19 @@ class Markdown(object):
_code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.+?[*_]*)(?<=\S)\*\*", re.S)
_code_friendly_em_re = re.compile(r"\*(?=\S)(.+?)(?<=\S)\*", re.S)
_code_friendly_line_re = re.compile(r"\~\~(?=\S)(.+?)(?<=\S)\~\~", re.S)
_code_friendly_underline_re = re.compile(r"\~(?=\S)(.+?)(?<=\S)\~", re.S)
def _do_italics_and_bold(self, text):
# <strong> must go first:
if "code-friendly" in self.extras:
text = self._code_friendly_strong_re.sub(r"<strong>\1</strong>", text)
text = self._code_friendly_em_re.sub(r"<em>\1</em>", text)
text = self._code_friendly_line_re.sub(r"<span style='text-decoration:line-through'>\1</span>", text)
text = self._code_friendly_underline_re.sub(r"<span style='text-decoration:underline'>\1</span>", text)
else:
text = self._strong_re.sub(r"<strong>\2</strong>", text)
text = self._em_re.sub(r"<em>\2</em>", text)
text = self._code_friendly_line_re.sub(r"<span style='text-decoration:line-through'>\1</span>", text)
text = self._code_friendly_underline_re.sub(r"<span style='text-decoration:underline'>\1</span>", text)
return text
# "smarty-pants" extra: Very liberal in interpreting a single prime as an

View File

@ -46,6 +46,7 @@ Available tags:
<pre style="display:inline">_italic_</pre> <span style="font-style:italic">italic</span><br/>
<pre style="display:inline">**bold**</pre> <span style="font-weight:bold">bold</span><br/>
<pre style="display:inline">~~line through~~</pre> <span style="text-decoration:line-through">line through</span><br/>
<pre style="display:inline">~underline~</pre> <span style="text-decoration:underline">underline</span><br/>
<pre style="display:inline">>Citation</pre><br/>
<pre>
* Unordered list

View File

@ -58,6 +58,7 @@ Available tags:
<pre style="display:inline">_italic_</pre> <span style="font-style:italic">italic</span><br/>
<pre style="display:inline">**bold**</pre> <span style="font-weight:bold">bold</span><br/>
<pre style="display:inline">~~line through~~</pre> <span style="text-decoration:line-through">line through</span><br/>
<pre style="display:inline">~underline~</pre> <span style="text-decoration:underline">underline</span><br/>
<pre style="display:inline">>Citation</pre><br/>
<pre>
* Unordered list

View File

@ -19,6 +19,10 @@
<br/><br/>
{% endautoescape %}
{% endif %}
<form action="/blog/search/{{ blog.id }}" method="post">
{% csrf_token %}
<input name="text"/><input type="submit" name="search" value="Search" />
</form>
{% if posts|length == 0 %}
<br/><br/>
<b>Any post available</b><br/><br/>