Markdown: Convert Markdown via Jinja filter in the template

This gets rid of the use of javascript for converting node/post description.
Now we only use markdown.js for real time as-we-type stuff, like node/post
editing or commenting.
This commit is contained in:
Pablo Vazquez 2017-11-23 16:49:19 +01:00
parent c086cff36e
commit 7252055e4a
11 changed files with 11 additions and 23 deletions

View File

@ -1,17 +1,5 @@
script(type="text/javascript"). script(type="text/javascript").
/* Convert Markdown */
var convert_fields = '.node-details-description, .blog_index-item .item-content';
var convert = new Markdown.getSanitizingConverter();
Markdown.Extra.init(convert);
convert = convert.makeHtml;
/* Parse description/content fields to convert markdown */
$(convert_fields).each(function(i){
$(convert_fields).eq(i).html(convert($(convert_fields).eq(i).text()));
});
ProjectUtils.setProjectAttributes({isProject: false}); ProjectUtils.setProjectAttributes({isProject: false});
// Click anywhere in the page to hide the overlay // Click anywhere in the page to hide the overlay

View File

@ -18,7 +18,7 @@
| {% if node.description %} | {% if node.description %}
.node-details-description#node-description .node-details-description#node-description
| {{node.description}} | {{ node.description | markdown }}
| {% endif %} | {% endif %}
include ../../_node_details include ../../_node_details

View File

@ -18,7 +18,7 @@
| {% if node.description %} | {% if node.description %}
.node-details-description#node-description .node-details-description#node-description
| {{node.description}} | {{ node.description | markdown }}
| {% endif %} | {% endif %}
include ../../_node_details include ../../_node_details

View File

@ -40,7 +40,7 @@
| {% if node.description %} | {% if node.description %}
.node-details-description#node-description .node-details-description#node-description
| {{node.description}} | {{ node.description | markdown }}
| {% endif %} | {% endif %}
include ../../_node_details include ../../_node_details

View File

@ -25,7 +25,7 @@ a.blog_index-header(href="{{ node.url }}")
| {{ node.name }} | {{ node.name }}
.item-content .item-content
| {{ node.properties.content }} | {{ node.properties.content | markdown }}
| {% endmacro %} | {% endmacro %}

View File

@ -15,7 +15,7 @@
| {% if node.description %} | {% if node.description %}
.node-details-description .node-details-description
| {{node.description}} | {{ node.description | markdown }}
| {% endif %} | {% endif %}
section.node-children.group section.node-children.group

View File

@ -12,7 +12,7 @@
| {% if node.description %} | {% if node.description %}
section.node-row section.node-row
.node-details-description .node-details-description
| {{node.description}} | {{ node.description | markdown }}
| {% endif %} | {% endif %}
| {% if children %} | {% if children %}

View File

@ -12,7 +12,7 @@
| {% if node.description %} | {% if node.description %}
section.node-row section.node-row
.node-details-description .node-details-description
| {{node.description}} | {{ node.description | markdown }}
| {% endif %} | {% endif %}
| {% if children %} | {% if children %}

View File

@ -93,7 +93,7 @@
| {% if node.description %} | {% if node.description %}
.node-details-description#node-description .node-details-description#node-description
| {{node.description}} | {{ node.description | markdown }}
| {% endif %} | {% endif %}
| {% if node.properties.license_notes %} | {% if node.properties.license_notes %}

View File

@ -17,7 +17,7 @@
| {% if node.description %} | {% if node.description %}
.node-details-description#node-description .node-details-description#node-description
| {{node.description}} | {{ node.description | markdown }}
| {% endif %} | {% endif %}
.node-details-meta.footer .node-details-meta.footer
@ -32,7 +32,7 @@ script.
// Push the correct URL onto the history. This push happens after the id has // Push the correct URL onto the history. This push happens after the id has
// been pushed to the history already. We should probably keep only this and // been pushed to the history already. We should probably keep only this and
// skip the project-level displayNode push. // skip the project-level displayNode push.
var url = '{{ node.properties.url }}' var url = '{{ node.properties.url }}'
var replace_state = {nodeId: '{{node._id}}', url: url}; var replace_state = {nodeId: '{{node._id}}', url: url};
window.history.replaceState( window.history.replaceState(

View File

@ -39,7 +39,7 @@
| {% if project.description %} | {% if project.description %}
.node-details-description .node-details-description
| {{ project.description }} | {{ project.description | markdown }}
| {% endif %} | {% endif %}
| {# Until we implement urls for pages | {# Until we implement urls for pages