Skip to content

Commit

Permalink
Misc (#537)
Browse files Browse the repository at this point in the history
* closes #530

* closes #495

* closes #512

* whitespace

* closes #514

* closes #494 by modifying the python script a touch

* small fix

* small fix

* finally ok

* some more silliness
  • Loading branch information
tlienart authored Jun 23, 2020
1 parent 7bd763f commit 9ba09de
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 24 deletions.
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This document keeps track of **key new features**, **breaking changes** and what

You can also check out [this issue](https://github.com/tlienart/Franklin.jl/issues/323) with a more granular list of things that are being worked on / have been fixed / added.

## 0.8+ (ongoing)

* `\underline` is not a thing anymore (I don't think anyone was using it) so that it doesn't clash with KaTeX's underline ([#512](https://github.com/tlienart/Franklin.jl/issues/512)); prefer `\style` for such things.
* files ending with `.min.css` are now **not** minified to avoid rare problems where the minifier would actually break an already minified file ([#494](https://github.com/tlienart/Franklin.jl/issues/494))

## v0.8

This minor releases should have no breaking changes compared to 0.7 apart from a slew of bug fixes.
Expand All @@ -27,7 +32,7 @@ At the core you can:

Finally you can also use `{{ispage /tag/tag1/}}` etc in the `_layout/tag.html` in order to specify a layout that would be dependent upon the tag name.

As usual, your feedback and suggestions are welcome, kindly open issues on GitHub. _Please make it easy for me to help you by giving me as much concise information as possible_.
As usual, your feedback and suggestions are welcome, kindly open issues on GitHub. _Please make it easy for me to help you by giving me as much concise information as possible_.

## v0.7

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Franklin"
uuid = "713c75ef-9fc9-4b05-94a9-213340da978e"
authors = ["Thibaut Lienart <[email protected]>"]
version = "0.8.4"
version = "0.8.5"

This comment has been minimized.

Copy link
@tlienart

tlienart Jun 23, 2020

Author Owner

[deps]
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<a href="https://franklinjl.org">
<img src="https://franklinjl.org/assets/infra/logoF2.svg" alt="Franklin" width="150">
<img src="https://franklinjl.org/assets/infra/logoF2.svg" alt="Franklin" width="100">
</a>
</div>

Expand All @@ -26,13 +26,14 @@
Franklin is a simple **static site generator** (SSG) oriented towards technical blogging (code, maths, ...) and light, fast-loading pages.
The base syntax is plain markdown with a few extensions such as the ability to define and use LaTeX-like commands in or outside of maths environments and the possibility to evaluate code blocks on the fly.

Franklin now has a channel/stream **#franklin** on both the Julia slack and Zulip.
Franklin now has a channel/stream **#franklin** on the Julia slack, this is the best place to ask usage question.
For anything that looks suspicious, feel free to open an issue here directly.

## Docs

Go to [Franklin's main website](https://franklinjl.org).

Some examples of websites using Franklin
Some examples of websites using Franklin (_if you're using Franklin with a public repo, consider adding the "franklin" tag to the repo to help others find examples, thanks!_)

* Franklin's own website is written in Franklin, [source](https://github.com/tlienart/franklindocs)
* The [Julia website](https://julialang.org), including the blog, are deployed in Franklin.
Expand All @@ -44,7 +45,7 @@ Some examples of websites using Franklin
* [@Wikunia's blog](https://opensourc.es) using the vela template
* [@zdroid's blog and website](https://zdroid.github.io) using Bootstrap 4.5
* [PkgPage.jl](https://tlienart.github.io/PkgPage.jl/), front-page generator based on Franklin
* [My website](https://tlienart.github.io).
* [My website](https://tlienart.github.io) (_by now a bit outdated... there's only so much one can do in a day_)

## Key features

Expand Down
23 changes: 12 additions & 11 deletions src/converter/html/blocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ function process_html_cond(hs::AS, qblocks::Vector{AbstractBlock},
# if its not just a {{if...}}, need to act appropriately
# and if the condition is verified then k=1
βi = qblocks[init_idx]
if βi isa Union{HIsDef,HIsNotDef,HIsPage,HIsNotPage}
if βi isa HTML_OPEN_COND_SP
lag = 1
if βi isa HIsDef
k = Int(haskey(LOCAL_VARS, βi.vname))
elseif βi isa HIsNotDef
k = Int(!haskey(LOCAL_VARS, βi.vname))
if !(βi isa Union{HIsPage, HIsNotPage})
k = haskey(LOCAL_VARS, βi.vname)
if !k
k = βi isa HIsNotDef
elseif βi isa Union{HIsEmpty, HIsNotEmpty}
v = locvar(βi.vname)
e = isempty(v)
k = ifelse(βi isa HIsEmpty, e, !e)
end
else
# HIsPage//HIsNotPage
rpath = splitext(unixify(locvar("fd_rpath")))[1]
Expand All @@ -88,13 +93,9 @@ function process_html_cond(hs::AS, qblocks::Vector{AbstractBlock},

# compare with β.pages
inpage = any(p -> match_url(rpath, p), βi.pages)

if βi isa HIsPage
k = Int(inpage)
else
k = Int(!inpage)
end
k = ifelse(βi isa HIsPage, inpage, !inpage)
end
k = Int(k) # either 0 (not found) or 1 (found and first)
end

# If we've not yet found a verified condition, keep looking
Expand Down
1 change: 1 addition & 0 deletions src/converter/html/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function process_html_qblocks(hs::AS, qblocks::Vector{AbstractBlock},
return String(take!(htmls))
end


"""
match_url(base, cand)
Expand Down
1 change: 0 additions & 1 deletion src/converter/latex/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const LX_INTERNAL_COMMANDS = [
# DERIVED / EXPLICIT
lxd("fig", 1, "\\figalt{}{#1}"),
lxd("style", 2, "~~~<span style=\"!#1\">~~~!#2~~~</span>~~~"),
lxd("underline", 1, "\\style{text-decoration:underline}{!#1}"),
lxd("tableofcontents", 0, "\\toc"),
lxd("codeoutput", 1, "\\output{#1}"), # \codeoutput{rpath}
]
Expand Down
15 changes: 12 additions & 3 deletions src/parser/html/blocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ function qualify_html_hblocks(blocks::Vector{OCBlock})::Vector{AbstractBlock}
# isdef block
m = match(HBLOCK_ISDEF_PAT, β.ss)
isnothing(m) || (qb[i] = HIsDef.ss, m.captures[1]); continue)
# ifndef block
# isnotdef block
m = match(HBLOCK_ISNOTDEF_PAT, β.ss)
isnothing(m) || (qb[i] = HIsNotDef.ss, m.captures[1]); continue)
# ---
# isempty block
m = match(HBLOCK_ISEMPTY_PAT, β.ss)
isnothing(m) || (qb[i] = HIsEmpty.ss, m.captures[1]); continue)
# isnotempty block
m = match(HBLOCK_ISNOTEMPTY_PAT, β.ss)
isnothing(m) || (qb[i] = HIsNotEmpty.ss, m.captures[1]); continue)
# ---
# ispage block
m = match(HBLOCK_ISPAGE_PAT, β.ss)
isnothing(m) || (qb[i] = HIsPage.ss, split(m.captures[1])); continue)
Expand Down Expand Up @@ -64,10 +71,12 @@ function qualify_html_hblocks(blocks::Vector{OCBlock})::Vector{AbstractBlock}
return qb
end

"""Blocks that can open a conditional block which are special."""
const HTML_OPEN_COND_SP =
Union{HIsDef, HIsNotDef, HIsEmpty, HIsNotEmpty, HIsPage, HIsNotPage}

"""Blocks that can open a conditional block."""
const HTML_OPEN_COND = Union{HIf,HIsDef,HIsNotDef,HIsPage,HIsNotPage}

const HTML_OPEN_COND = Union{HIf, HTML_OPEN_COND_SP}

"""
$SIGNATURES
Expand Down
26 changes: 26 additions & 0 deletions src/parser/html/tokens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,31 @@ struct HIsNotDef <: AbstractBlock
vname::String
end

# ----------------------------------------------------------
# Specific conditional block based on whether a var is empty
# ----------------------------------------------------------

"""
$(TYPEDEF)
HTML token corresponding to `{{isempty var}}`.
"""
struct HIsEmpty <: AbstractBlock
ss::SubString
vname::String
end


"""
$(TYPEDEF)
HTML token corresponding to `{{isnotempty var}}`.
"""
struct HIsNotEmpty <: AbstractBlock
ss::SubString
vname::String
end

# ------------------------------------------------------------
# Specific conditional block based on whether the current page
# is or isn't in a group of given pages
Expand All @@ -156,6 +181,7 @@ struct HIsNotPage <: AbstractBlock
pages::Vector{<:AS}
end


"""
$(TYPEDEF)
Expand Down
3 changes: 3 additions & 0 deletions src/regexes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ const HBLOCK_END_PAT = Regex(HBO * "end" * HBC)
const HBLOCK_ISDEF_PAT = Regex(HBO * raw"i(?:s|f)def\s+" * VAR * HBC)
const HBLOCK_ISNOTDEF_PAT = Regex(HBO * raw"i(?:s|f)n(?:ot)?def\s+" * VAR * HBC)

const HBLOCK_ISEMPTY_PAT = Regex(HBO * raw"i(?:s|f)empty\s+" * VAR * HBC)
const HBLOCK_ISNOTEMPTY_PAT = Regex(HBO * raw"i(?:s|f)n(?:ot)?empty\s+" * VAR * HBC)

const HBLOCK_ISPAGE_PAT = Regex(HBO * raw"ispage\s+" * ANY * HBC)
const HBLOCK_ISNOTPAGE_PAT = Regex(HBO * raw"isnotpage\s+" * ANY * HBC)

Expand Down
10 changes: 7 additions & 3 deletions src/scripts/minify.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This is a simple script using `css_html_js_minify` (available via pip) to compress html and css
# files (the js that we use is already compressed). This script takes negligible time to run.
# This is a simple script using `css_html_js_minify` (available via pip)
# to compress html and css files (the js that we use is already compressed).
# This script takes negligible time to run.

import os
from css_html_js_minify import process_single_html_file as min_html
Expand All @@ -17,7 +18,6 @@
html_files.append(os.path.join(root, fname))

css_files = []

for root, dirs, files in os.walk(CSS):
for fname in files:
if fname.endswith(".css"):
Expand All @@ -32,6 +32,10 @@
if fname.endswith(".css"):
css_files.append(os.path.join(root, fname))


css_files = [cf for cf in css_files if not cf.endswith(".min.css")]


if os.name == 'nt':
# multiprocessing doesn't seem to go well with windows...
for file in html_files:
Expand Down
13 changes: 13 additions & 0 deletions test/converter/html/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,16 @@ end

set_curpath("index.md")
end

@testset "Cond isempty" begin
F.def_LOCAL_VARS!()
F.set_vars!(F.LOCAL_VARS, [
"b1" => "\"\"",
"b2" => "\"hello\""])
fdc = x->F.convert_html(x)

@test "{{isempty b1}}blah{{else}}blih{{end}}" |> fdc == "blah"
@test "{{isnotempty b2}}blah{{else}}blih{{end}}" |> fdc == "blah"
@test "{{isempty b2}}blah{{else}}blih{{end}}" |> fdc == "blih"
@test "{{isnotempty b1}}blah{{else}}blih{{end}}" |> fdc == "blih"
end

1 comment on commit 9ba09de

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/16804

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.5 -m "<description of version>" 9ba09dec6fb5d1b8a16ab9510eddb3eff4cd27e6
git push origin v0.8.5

Please sign in to comment.