Skip to content

Commit

Permalink
make criticnav text to avoid it beeing in head
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed May 5, 2023
1 parent 29f8319 commit 1b89285
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 64 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ filters:

Here is a minimal example showing the critic markup syntax and its rendering: [example.qmd](example.qmd).

This is the output of [example.qmd](example.qmd).
This is the output of [example.qmd](https://mloubout.github.io/critic-markup/).
69 changes: 61 additions & 8 deletions _extensions/critic-markup/critic-markup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,55 @@ local scriptcode = [[
</ul>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="_extensions/critic-markup/critic.js"></script>
<script type="text/javascript">
function critic() {
$('.fullcontent').addClass('markup');
$('#markup-button').addClass('active');
$('ins.break').unwrap();
$('span.critic.comment').wrap('<span class="popoverc" /></span>');
$('span.critic.comment').before('&#8225;');
}
function original() {
$('#original-button').addClass('active');
$('#edited-button').removeClass('active');
$('#markup-button').removeClass('active');
$('.fullcontent').addClass('original');
$('.fullcontent').removeClass('edited');
$('.fullcontent').removeClass('markup');
}
function edited() {
$('#original-button').removeClass('active');
$('#edited-button').addClass('active');
$('#markup-button').removeClass('active');
$('.fullcontent').removeClass('original');
$('.fullcontent').addClass('edited');
$('.fullcontent').removeClass('markup');
}
function markup() {
$('#original-button').removeClass('active');
$('#edited-button').removeClass('active');
$('#markup-button').addClass('active');
$('.fullcontent').removeClass('original');
$('.fullcontent').removeClass('edited');
$('.fullcontent').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)
Expand Down Expand Up @@ -69,12 +116,18 @@ if FORMAT:match 'html' then
-- 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' then
if inlines[i+1].t == 'Str' and inlines[i+1].text == "}" then
inlines:remove(i+1)
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 == "}" then
inlines:remove(i+1)
end
end
if inlines[i-1].t == 'Str' and inlines[i-1].text == "{" then
inlines:remove(i-1)
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 == "{" then
inlines:remove(i-1)
end
end
end
end
Expand Down Expand Up @@ -106,9 +159,9 @@ 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
Expand Down
1 change: 1 addition & 0 deletions _extensions/critic-markup/critic.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.fullcontent {
padding-top: 30px !important;
}

#criticnav {
position: fixed;
z-index: 1100;
Expand Down
47 changes: 0 additions & 47 deletions _extensions/critic-markup/critic.js

This file was deleted.

5 changes: 5 additions & 0 deletions _extensions/critic-markup/critic.min.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions example.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ This filter adds processing of critic markdown syntax. Below are examples of usa

## Highlighting

{==Highlighted text==}
`{==Highlighted text==}` {==Highlighted text==}

{== Highlighted text with a comment==}{>>First comment<<}
`{== Highlighted text with a comment==}{>>First comment<<}` {== Highlighted text with a comment==}{>>First comment<<}

{>>Single comment <<}
`{>>Single comment <<}` {>>Single comment <<}


## Addition

{++This is added text++}
`{++This is added text++}` {++This is added text++}

{++This is added text with some removed++}{-- removed--}
`{++This is added text with some removed++}{-- removed--}` {++This is added text with some removed++}{-- removed--}


## Deletion

{--This is removed text--}
`{--This is removed text--}` {--This is removed text--}

{--This is removed text with some added--}{++added ++}
`{--This is removed text with some added--}{++added ++}` {--This is removed text with some added--}{++added ++}

## Replacement

{~~This is original text~> this is the replacement~~}
`{~~This is original text~> this is the replacement~~}` {~~This is original text~> this is the replacement~~}

0 comments on commit 1b89285

Please sign in to comment.