add extensions
This commit is contained in:
8
_extensions/mloubout/critic-markup/_extension.yml
Normal file
8
_extensions/mloubout/critic-markup/_extension.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
title: Critic-markup
|
||||
author: mloubout
|
||||
version: 1.0.3
|
||||
quarto-required: ">=1.2.198"
|
||||
contributes:
|
||||
filters:
|
||||
- critic-markup.lua
|
||||
|
||||
174
_extensions/mloubout/critic-markup/critic-markup.lua
Normal file
174
_extensions/mloubout/critic-markup/critic-markup.lua
Normal file
@@ -0,0 +1,174 @@
|
||||
|
||||
local maybesubs = false
|
||||
local stk_end = false
|
||||
|
||||
add = pandoc.RawInline('html', "<ins>")
|
||||
adde = pandoc.RawInline('html', "</ins>")
|
||||
|
||||
rm = pandoc.RawInline('html', "<del>")
|
||||
rme = pandoc.RawInline('html', "</del>")
|
||||
rmeadd = pandoc.RawInline('html', "</del><ins>")
|
||||
|
||||
mark = pandoc.RawInline('html', "<mark>")
|
||||
marke = pandoc.RawInline('html', "</mark>")
|
||||
|
||||
comm = pandoc.RawInline('html', [[<span class="critic comment">]])
|
||||
comme = pandoc.RawInline('html', "</span>")
|
||||
|
||||
ruless = {['{%+%+']=add, ['{\u{2013}']=rm, ['{==']=mark, ['{>>']=comm, ['{~~']=rm,
|
||||
['%+%+}']=adde, ['\u{2013}}']=rme, ['==}']=marke, ['<<}']=comme, ['~~}']=rme, ['~>']=rmeadd}
|
||||
|
||||
-- Strikeout before/after
|
||||
st_b = '{'
|
||||
st_e = '}'
|
||||
|
||||
local scriptcode = [[
|
||||
|
||||
<div id="criticnav">
|
||||
<ul>
|
||||
<li id="markup-button">Markup</li>
|
||||
<li id="original-button">Original</li>
|
||||
<li id="edited-button">Edited</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function critic() {
|
||||
|
||||
$('.content').addClass('markup');
|
||||
$('#markup-button').addClass('active');
|
||||
$('ins.break').unwrap();
|
||||
$('span.critic.comment').wrap('<span class="popoverc" /></span>');
|
||||
$('span.critic.comment').before('‡');
|
||||
}
|
||||
|
||||
function original() {
|
||||
$('#original-button').addClass('active');
|
||||
$('#edited-button').removeClass('active');
|
||||
$('#markup-button').removeClass('active');
|
||||
|
||||
$('.content').addClass('original');
|
||||
$('.content').removeClass('edited');
|
||||
$('.content').removeClass('markup');
|
||||
}
|
||||
|
||||
function edited() {
|
||||
$('#original-button').removeClass('active');
|
||||
$('#edited-button').addClass('active');
|
||||
$('#markup-button').removeClass('active');
|
||||
|
||||
$('.content').removeClass('original');
|
||||
$('.content').addClass('edited');
|
||||
$('.content').removeClass('markup');
|
||||
}
|
||||
|
||||
function markup() {
|
||||
$('#original-button').removeClass('active');
|
||||
$('#edited-button').removeClass('active');
|
||||
$('#markup-button').addClass('active');
|
||||
|
||||
$('.content').removeClass('original');
|
||||
$('.content').removeClass('edited');
|
||||
$('.content').addClass('markup');
|
||||
}
|
||||
|
||||
var o = document.getElementById("original-button");
|
||||
var e = document.getElementById("edited-button");
|
||||
var m = document.getElementById("markup-button");
|
||||
|
||||
window.onload = critic();
|
||||
o.onclick = original;
|
||||
e.onclick = edited;
|
||||
m.onclick = markup;
|
||||
</script>
|
||||
]]
|
||||
|
||||
function cirtiblock(blocks, k, v)
|
||||
local newblock = {}
|
||||
for ti,t in pairs(blocks) do
|
||||
if t.text then
|
||||
i, j = t.text:find(k)
|
||||
if i then
|
||||
newblock[#newblock + 1] = pandoc.Str(t.text:sub(1, i-1))
|
||||
newblock[#newblock + 1] = v
|
||||
newblock[#newblock + 1] = pandoc.Str(t.text:sub(j+1, t.text:len()))
|
||||
else
|
||||
newblock[#newblock + 1] = t
|
||||
end
|
||||
else
|
||||
newblock[#newblock + 1] = t
|
||||
end
|
||||
end
|
||||
return newblock
|
||||
end
|
||||
|
||||
|
||||
if FORMAT:match 'html' then
|
||||
|
||||
function Str (el)
|
||||
local replaced = {el}
|
||||
-- Check for standard substitutions
|
||||
for k,v in pairs(ruless) do
|
||||
replaced = cirtiblock(replaced, k, v)
|
||||
end
|
||||
return replaced
|
||||
end
|
||||
|
||||
function Strikeout (strk)
|
||||
return strk.content
|
||||
end
|
||||
|
||||
-- Check Inlines for Strikeout (~~) and remove brackets before/after for replacement
|
||||
function Inlines (inlines)
|
||||
for i = #inlines-1,2,-1 do
|
||||
if inlines[i] and inlines[i].t == 'Strikeout' and inlines[i+1] then
|
||||
if inlines[i+1].t == 'Str' then
|
||||
if inlines[i+1].text == st_e then
|
||||
inlines[i+1] = adde
|
||||
end
|
||||
end
|
||||
end
|
||||
if inlines[i] and inlines[i].t == 'Strikeout' and inlines[i-1] then
|
||||
if inlines[i-1].t == 'Str' then
|
||||
if inlines[i-1].text == st_b then
|
||||
inlines[i-1] = rm
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return inlines
|
||||
end
|
||||
end
|
||||
|
||||
--- From the lightbox filter
|
||||
local function add_header_includes(meta, blocks)
|
||||
|
||||
local header_includes = pandoc.List(blocks)
|
||||
|
||||
-- add any exisiting meta['header-includes']
|
||||
-- it could be a MetaList or a single String
|
||||
if meta['header-includes'] then
|
||||
if type(meta['header-includes']) == 'List' then
|
||||
header_includes:extend(meta['header-includes'])
|
||||
else
|
||||
header_includes:insert(meta['header-includes'])
|
||||
end
|
||||
end
|
||||
|
||||
meta['header-includes'] = pandoc.MetaBlocks(header_includes)
|
||||
return meta
|
||||
end
|
||||
|
||||
|
||||
function criticheader (meta)
|
||||
quarto.doc.add_html_dependency({
|
||||
name = 'critic',
|
||||
scripts = {'critic.min.js'},
|
||||
stylesheets = {'critic.css'}
|
||||
})
|
||||
-- inject the rendering code
|
||||
quarto.doc.include_text("after-body", scriptcode)
|
||||
end
|
||||
|
||||
-- All pass with Meta first
|
||||
return {{Meta = criticheader}, {Inlines = Inlines}, {Strikeout = Strikeout}, {Str = Str}}
|
||||
131
_extensions/mloubout/critic-markup/critic.css
Normal file
131
_extensions/mloubout/critic-markup/critic.css
Normal file
@@ -0,0 +1,131 @@
|
||||
.fullcontent {
|
||||
padding-top: 30px !important;
|
||||
}
|
||||
|
||||
#criticnav {
|
||||
position: fixed;
|
||||
z-index: 1100;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
border-bottom: solid 1px #696f75;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: rgba(255,255,255,0.95);
|
||||
color: #696f75;
|
||||
font-size: 14px;
|
||||
font-family: "Helvetica Neue", helvetica, arial, sans-serif !important
|
||||
}
|
||||
|
||||
#criticnav ul {
|
||||
list-style-type: none;
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
padding: 0
|
||||
}
|
||||
|
||||
#criticnav ul li {
|
||||
display: block;
|
||||
width: 15%;
|
||||
min-width: 100px;
|
||||
text-align: center;
|
||||
padding: 5px 0 3px !important;
|
||||
margin: 5px 2px !important;
|
||||
line-height: 1em;
|
||||
float: left;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
-webkit-user-select: none;
|
||||
border-radius: 20px;
|
||||
border: 1px solid rgba(255,255,255,0);
|
||||
color: #777 !important
|
||||
}
|
||||
|
||||
#criticnav ul li:before {
|
||||
content: none !important
|
||||
}
|
||||
|
||||
#criticnav ul li.active {
|
||||
border: 1px solid #696f75
|
||||
}
|
||||
|
||||
.original del {
|
||||
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.original ins,
|
||||
.original span.popoverc,
|
||||
.original ins.break {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.edited ins {
|
||||
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.edited del,
|
||||
.edited span.popoverc,
|
||||
.edited ins.break {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.original mark,
|
||||
.edited mark {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.markup mark {
|
||||
background-color: #fffd38;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.markup del {
|
||||
background-color: rgba(183,47,47,0.4);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.markup ins {
|
||||
background-color: rgba(152,200,86,0.4);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.markup ins.break {
|
||||
display: block;
|
||||
line-height: 2px;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.markup ins.break span {
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
.markup .popoverc {
|
||||
background-color: #e5b000;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.markup .popoverc .critic.comment {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.markup .popoverc:hover span.critic.comment {
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 200px;
|
||||
left: 30%;
|
||||
font-size: 0.8em;
|
||||
color: #ccc;
|
||||
background-color: #333;
|
||||
z-index: 10;
|
||||
padding: 0.5em 1em;
|
||||
border-radius: 0.5em;
|
||||
}
|
||||
|
||||
@media print {
|
||||
#criticnav {
|
||||
display: none !important
|
||||
}
|
||||
}
|
||||
5
_extensions/mloubout/critic-markup/critic.min.js
vendored
Normal file
5
_extensions/mloubout/critic-markup/critic.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user