Commit 0b4c0be7 authored by alexandre's avatar alexandre
Browse files

Fixed footnote references

parent dbf6680d
......@@ -17,7 +17,6 @@
;(function(undefined) {
if (!Object.entries)
Object.entries = function( obj ){
var ownProps = Object.keys( obj ),
......@@ -39,6 +38,8 @@
const groupByRoles = groupBy('role');
const groupByLicence = groupBy('licence');
var fn_list = [];
function naturalJoin(names) {
let text = "";
......@@ -75,7 +76,8 @@
folio: {
default: 1,
type: Number
}
},
fn_list: []
},
data () {
return {
......@@ -212,6 +214,38 @@
},
folioCounter: function() {
return this.folio - 1;
},
footnotes_ordered: function() {
var ordered = [],
footnotes = this.footnotes
;
function find_by_uuid(uuid) {
return function(entry) {
return entry.uuid.startsWith(uuid);
}
}
fn_list.forEach(function(item, index) {
var fn = footnotes.find(find_by_uuid(item));
if (fn) { ordered.push(fn); }
});
return ordered;
}
},
methods: {
get_fn_index : function(val) {
var _id = val.substring(1,7);
if (fn_list.indexOf(_id) == -1) {
fn_list.push(_id);
};
return (fn_list.indexOf(_id) + 1);
},
process_fn_refs: function(value) {
return value.replace(/footnote/g, 'sup').replace(/\[[a-f0-9]{6}\]/g, this.get_fn_index);
}
},
template: `<article>
......@@ -238,7 +272,7 @@
</figure>
<template v-for="block in content">
<html-fragment :html="block.value" v-if="block && block.type == 'richtext'"></html-fragment>
<html-fragment :html="process_fn_refs(block.value)" v-if="block && block.type == 'richtext'"></html-fragment>
<aside v-if="block && block.type == 'pullout'" class="pull-out">
<blockquote>
......@@ -293,7 +327,7 @@
</footer>
<ol v-if="footnotes" class="footnotes">
<li v-for="footnote in footnotes" v-html="footnote.content"></li>
<li v-for="footnote in footnotes_ordered" v-html="footnote.content"></li>
</ol>
</article>`,
mounted () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment