Repository: tlienart/Franklin.jl
Pull request #343 (2020-01-22 15:31:52)

Divfix


Patch:
diff --git a/src/parser/html_blocks.jl b/src/parser/html_blocks.jl
index 72fea1e5..3852fe09 100644
--- a/src/parser/html_blocks.jl
+++ b/src/parser/html_blocks.jl
@@ -1,8 +1,8 @@
 """
 $(SIGNATURES)
 
-Given `{{ ... }}` blocks, identify what kind of blocks they are and return a vector
-of qualified blocks of type `AbstractBlock`.
+Given `{{ ... }}` blocks, identify what kind of blocks they are and return a
+vector of qualified blocks of type `AbstractBlock`.
 """
 function qualify_html_hblocks(blocks::Vector{OCBlock})::Vector{AbstractBlock}
 
diff --git a/src/parser/html_tokens.jl b/src/parser/html_tokens.jl
index c2131ea1..59886b14 100644
--- a/src/parser/html_tokens.jl
+++ b/src/parser/html_tokens.jl
@@ -10,8 +10,9 @@ const HTML_1C_TOKENS = LittleDict{Char, Symbol}()
 """
 HTML_TOKENS
 
-Dictionary of tokens for HTML. Note that for each, there may be several possibilities to consider
-in which case the order is important: the first case that works will be taken.
+Dictionary of tokens for HTML. Note that for each, there may be several
+possibilities to consider in which case the order is important: the first case
+that works will be taken.
 """
 const HTML_TOKENS = LittleDict{Char, Vector{TokenFinder}}(
     '<' => [ isexactly("<!--") => :COMMENT_OPEN  ],  # <!-- ...
@@ -180,8 +181,9 @@ FUNCTION BLOCKS
 """
 HBLOCK_FUN_PAT
 
-Regex to match `{{ fname param₁ param₂ }}` where `fname` is a html processing function and `paramᵢ`
-should refer to appropriate variables in the current scope.
+Regex to match `{{ fname param₁ param₂ }}` where `fname` is a html processing
+function and `paramᵢ` should refer to appropriate variables in the current
+scope.
 
 Available functions are:
     * `{{ fill vname }}`: to plug a variable (e.g.: a date, author name)
diff --git a/src/parser/indent.jl b/src/parser/indent.jl
index a160eeeb..4db76ebd 100644
--- a/src/parser/indent.jl
+++ b/src/parser/indent.jl
@@ -1,9 +1,9 @@
 """
 $(SIGNATURES)
 
-In initial phase, discard all `:LR_INDENT` that don't meet the requirements for an
-indented code block. I.e.: where the first  line is not preceded by a blank line and
-then subsequently followed by indented lines.
+In initial phase, discard all `:LR_INDENT` that don't meet the requirements for
+an indented code block. I.e.: where the first  line is not preceded by a blank
+line and then subsequently followed by indented lines.
 """
 function filter_lr_indent!(vt::Vector{Token}, s::String)::Nothing
     tind_idx = [i for i in eachindex(vt) if vt[i].name == :LR_INDENT]
@@ -44,7 +44,8 @@ end
 """
 $(SIGNATURES)
 
-Find markers for indented lines (i.e. a line return followed by a tab or 4 spaces).
+Find markers for indented lines (i.e. a line return followed by a tab or 4
+spaces).
 """
 function find_indented_blocks!(tokens::Vector{Token}, st::String)::Nothing
     # index of the line return tokens
@@ -89,8 +90,8 @@ end
 """
 $SIGNATURES
 
-When two indented code blocks follow each other and there's nothing in between (empty line(s)),
-merge them into a super block.
+When two indented code blocks follow each other and there's nothing in between
+(empty line(s)), merge them into a super block.
 """
 function merge_indented_blocks!(blocks::Vector{OCBlock}, mds::AS)::Nothing
     # indices of CODE_BLOCK_IND
@@ -141,7 +142,8 @@ end
 """
 $SIGNATURES
 
-Discard any indented block that is within a larger block to avoid ambiguities (see #285).
+Discard any indented block that is within a larger block to avoid ambiguities
+(see #285).
 """
 function filter_indented_blocks!(blocks::Vector{OCBlock})::Nothing\
     # retrieve the indices of the indented blocks
diff --git a/src/parser/lx_blocks.jl b/src/parser/lx_blocks.jl
index 9af96225..e473eb18 100644
--- a/src/parser/lx_blocks.jl
+++ b/src/parser/lx_blocks.jl
@@ -1,11 +1,13 @@
 """
 $(SIGNATURES)
 
-Find `\\newcommand` elements and try to parse what follows to form a proper Latex command.
-Return a list of such elements.
+Find `\\newcommand` elements and try to parse what follows to form a proper
+Latex command. Return a list of such elements.
 
 The format is:
+
     \\newcommand{NAMING}[NARG]{DEFINING}
+
 where [NARG] is optional (see `LX_NARG_PAT`).
 """
 function find_md_lxdefs(tokens::Vector{Token}, blocks::Vector{OCBlock})
@@ -44,8 +46,8 @@ function find_md_lxdefs(tokens::Vector{Token}, blocks::Vector{OCBlock})
         if !isempty(rge)
             lxnarg = match(LX_NARG_PAT, subs(str(braces[k]), rge))
             if isnothing(lxnarg)
-                throw(LxDefError("Ill formed newcommand (where I expected the "*
-                                 "specification of the number of arguments)."))
+                throw(LxDefError("Ill formed newcommand (where I expected " *
+                                 "the specification of the number of " * "arguments)."))
             end
             matched = lxnarg.captures[2]
             lxnarg = isnothing(matched) ? 0 : parse(Int, matched)
@@ -57,8 +59,8 @@ function find_md_lxdefs(tokens::Vector{Token}, blocks::Vector{OCBlock})
         # try to find a valid command name in the first set of braces
         matched = match(LX_NAME_PAT, content(naming_braces))
         if isnothing(matched)
-            throw(LxDefError("Invalid definition of a new command expected a command name " *
-                             "of the form `\\command`."))
+            throw(LxDefError("Invalid definition of a new command expected " *
+                             "a command name of the form `\\command`."))
         end
 
         # keep track of the command name, definition and where it stops
@@ -96,8 +98,9 @@ end
 $(SIGNATURES)
 
 Retrieve the reference pointing to a `LxDef` corresponding to a given `lxname`.
-If no reference is found but `inmath=true`, we propagate and let KaTeX deal with it. If something
-is found, the reference is returned and will be accessed further down.
+If no reference is found but `inmath=true`, we propagate and let KaTeX deal
+with it. If something is found, the reference is returned and will be accessed
+further down.
 """
 function retrieve_lxdefref(lxname::SubString, lxdefs::Vector{LxDef},
                            inmath::Bool=false, offset::Int=0)::Ref
@@ -154,9 +157,10 @@ function find_md_lxcoms(tokens::Vector{Token}, lxdefs::Vector{LxDef},
             b1_idx = findfirst(β -> (from(β) == nxtidx), braces)
             # --> it needs to exist + there should be enough braces left
             if isnothing(b1_idx) || (b1_idx + lxnarg - 1 > nbraces)
-                throw(LxComError("Command '$lxname' expects $lxnarg argument(s) and there " *
-                                 "should be no space(s) between the command name and the first " *
-                                 "brace: \\com{arg1}..."))
+                throw(LxComError("Command '$lxname' expects $lxnarg " *
+                                 "argument(s) and there should be no " *
+                                 "space(s) between the command name and " *
+                                 "the first brace: \\com{arg1}..."))
             end
 
             # --> examine candidate braces, there should be no spaces between
@@ -164,8 +168,10 @@ function find_md_lxcoms(tokens::Vector{Token}, lxdefs::Vector{LxDef},
             cand_braces = braces[b1_idx:b1_idx+lxnarg-1]
             for bidx ∈ 1:lxnarg-1
                 if (to(cand_braces[bidx]) + 1 != from(cand_braces[bidx+1]))
-                    throw(LxComError("Argument braces should not be separated by space(s): " *
-                                     "\\com{arg1}{arg2}... Verify a '$lxname' command."))
+                    throw(LxComError("Argument braces should not be " *
+                                     "separated by space(s): " *
+                                     "\\com{arg1}{arg2}... Verify a " *
+                                     "'$lxname' command."))
                 end
             end
 
diff --git a/src/parser/lx_tokens.jl b/src/parser/lx_tokens.jl
index 4c3fe1b6..b4d1f039 100644
--- a/src/parser/lx_tokens.jl
+++ b/src/parser/lx_tokens.jl
@@ -2,7 +2,9 @@
 LX_NAME_PAT
 
 Regex to find the name in a new command within a brace block. For example:
+
     \\newcommand{\\com}[2]{def}
+
 will give as first capture group `\\com`.
 """
 const LX_NAME_PAT = r"^\s*(\\[a-zA-Z]+)\s*$"
@@ -11,10 +13,13 @@ const LX_NAME_PAT = r"^\s*(\\[a-zA-Z]+)\s*$"
 """
 LX_NARG_PAT
 
-Regex to find the number of argument in a new command (if it is given). For example:
+Regex to find the number of argument in a new command (if it is given). For
+example:
+
     \\newcommand{\\com}[2]{def}
-will give as second capture group `2`. If there are no number of arguments, the second capturing
-group will be `nothing`.
+
+will give as second capture group `2`. If there are no number of arguments, the
+second capturing group will be `nothing`.
 """
 const LX_NARG_PAT = r"\s*(\[\s*(\d)\s*\])?\s*"
 
@@ -33,8 +38,8 @@ $(TYPEDEF)
 Structure to keep track of the definition of a latex command declared via a
 `\newcommand{\name}[narg]{def}`.
 
-NOTE: mutable so that we can modify the `from` element to mark it as zero when the command has been
-defined in the context of what we're currently parsing.
+NOTE: mutable so that we can modify the `from` element to mark it as zero when
+the command has been defined in the context of what we're currently parsing.
 """
 mutable struct LxDef
     name::String
@@ -57,16 +62,15 @@ to(lxd::LxDef)   = lxd.to
 """
 pastdef(λ)
 
-Convenience function to mark a definition as having been defined in the context i.e.: earlier than
-any other definition appearing in the current page.
+Convenience function to mark a definition as having been defined in the context
+i.e.: earlier than any other definition appearing in the current page.
 """
 pastdef(λ::LxDef) = LxDef(λ.name, λ.narg, λ.def)
 
 """
 $(TYPEDEF)
 
-A `LxCom` has a similar content as a `Block`, with the addition of the definition and a vector of
-brace blocks.
+A `LxCom` has a similar content as a `Block`, with the addition of the definition and a vector of brace blocks.
 """
 struct LxCom <: AbstractBlock
     ss    ::SubString       # \\command
@@ -81,8 +85,8 @@ to(lxc::LxCom) = to(lxc.ss)
 """
 $(SIGNATURES)
 
-For a given `LxCom`, retrieve the definition attached to the corresponding `LxDef` via the
-reference.
+For a given `LxCom`, retrieve the definition attached to the corresponding
+`LxDef` via the reference.
 """
 getdef(lxc::LxCom) = getindex(lxc.lxdef).def
 
diff --git a/src/parser/md_tokens.jl b/src/parser/md_tokens.jl
index 011de5dd..6aa6cd47 100644
--- a/src/parser/md_tokens.jl
+++ b/src/parser/md_tokens.jl
@@ -1,8 +1,8 @@
 """
 MD_1C_TOKENS
 
-Dictionary of single-char tokens for Markdown. Note that these characters are exclusive, they
-cannot appear again in a larger token.
+Dictionary of single-char tokens for Markdown. Note that these characters are
+exclusive, they cannot appear again in a larger token.
 """
 const MD_1C_TOKENS = LittleDict{Char, Symbol}(
     '{'  => :LXB_OPEN,
@@ -25,8 +25,9 @@ const MD_1C_TOKENS_LX = LittleDict{Char, Symbol}(
 """
 MD_TOKENS
 
-Dictionary of tokens for Markdown. Note that for each, there may be several possibilities to
-consider in which case the order is important: the first case that works will be taken.
+Dictionary of tokens for Markdown. Note that for each, there may be several
+possibilities to consider in which case the order is important: the first case
+that works will be taken.
 """
 const MD_TOKENS = LittleDict{Char, Vector{TokenFinder}}(
     '<'  => [ isexactly("<!--") => :COMMENT_OPEN,     # <!-- ...
@@ -112,7 +113,9 @@ const MD_TOKENS_LX = Dict{Char, Vector{TokenFinder}}(
 MD_DEF_PAT
 
 Regex to match an assignment of the form
+
     @def var = value
+
 The first group captures the name (`var`), the second the assignment (`value`).
 """
 const MD_DEF_PAT = r"@def\s+(\S+)\s*?=\s*?(\S.*)"
@@ -121,8 +124,8 @@ const MD_DEF_PAT = r"@def\s+(\S+)\s*?=\s*?(\S.*)"
 """
 L_RETURNS
 
-Convenience tuple containing the name for standard line returns and line returns followed by an
-indentation (either a quadruple space or a tab).
+Convenience tuple containing the name for standard line returns and line
+returns followed by an indentation (either a quadruple space or a tab).
 """
 const L_RETURNS = (:LINE_RETURN, :LR_INDENT, :EOS)
 
@@ -130,12 +133,14 @@ const L_RETURNS = (:LINE_RETURN, :LR_INDENT, :EOS)
 """
 MD_OCB
 
-List of Open-Close Blocks whose content should be deactivated (any token within their span
-should be marked as inactive) until further processing.
-The keys are identifier for the type of block, the value is a pair with the opening and closing
-tokens followed by a boolean indicating whether the content of the block should be reprocessed.
-The only `OCBlock` not in this dictionary is the brace block since it should not deactivate its
-content which is needed to find latex definitions (see parser/markdown/find_blocks/find_md_lxdefs).
+List of Open-Close Blocks whose content should be deactivated (any token within
+their span should be marked as inactive) until further processing.
+The keys are identifier for the type of block, the value is a pair with the
+opening and closing tokens followed by a boolean indicating whether the content
+of the block should be reprocessed.
+The only `OCBlock` not in this dictionary is the brace block since it should
+not deactivate its content which is needed to find latex definitions
+(see parser/markdown/find_blocks/find_md_lxdefs).
 """
 const MD_OCB = [
     # name                    opening token   closing token(s)  nestable
@@ -164,8 +169,9 @@ const MD_OCB = [
     OCProto(:DIV,             :DIV_OPEN,     (:DIV_CLOSE,), true ),
     ]
 #= NOTE:
-* [3] a header can be closed by either a line return or an end of string (for instance in the case
-where a user defines a latex command like so: \newcommand{\section}{# blah} (no line return).)
+* [3] a header can be closed by either a line return or an end of string (for
+instance in the case where a user defines a latex command like so:
+\newcommand{\section}{# blah} (no line return).)
 * [4] an `MD_DEF` goes from an `@def` to the next `\n` so no multiple-line
 def are allowed.
 * ordering matters!
@@ -179,6 +185,7 @@ All header symbols.
 """
 const MD_HEADER = (:H1, :H2, :H3, :H4, :H5, :H6)
 
+
 """
 MD_HEADER_OPEN
 
@@ -199,8 +206,8 @@ const MD_OCB_ESC = [e.name for e ∈ MD_OCB if !e.nest]
 """
 MD_OCB_MATH
 
-Same concept as `MD_OCB` but for math blocks, they can't be nested. Separating them from the other
-dictionary makes their processing easier.
+Same concept as `MD_OCB` but for math blocks, they can't be nested. Separating
+them from the other dictionary makes their processing easier.
 Dev note: order does not matter.
 """
 const MD_OCB_MATH = [
diff --git a/src/parser/md_validate.jl b/src/parser/md_validate.jl
index b0c7c86e..dc33a0fb 100644
--- a/src/parser/md_validate.jl
+++ b/src/parser/md_validate.jl
@@ -1,8 +1,9 @@
 """
 $SIGNATURES
 
-Find footnotes refs and defs and eliminate the ones that don't verify the appropriate regex.
-For a footnote ref: `\\[\\^[a-zA-Z0-0]+\\]` and `\\[\\^[a-zA-Z0-0]+\\]:` for the def.
+Find footnotes refs and defs and eliminate the ones that don't verify the
+appropriate regex. For a footnote ref: `\\[\\^[a-zA-Z0-0]+\\]` and
+`\\[\\^[a-zA-Z0-0]+\\]:` for the def.
 """
 function validate_footnotes!(tokens::Vector{Token})
     fn_refs = Vector{Token}()
@@ -38,8 +39,8 @@ end
 """
 $(SIGNATURES)
 
-Given a candidate header block, check that the opening `#` is at the start of a line, otherwise
-ignore the block.
+Given a candidate header block, check that the opening `#` is at the start of a
+line, otherwise ignore the block.
 """
 function validate_headers!(tokens::Vector{Token})::Nothing
     isempty(tokens) && return
diff --git a/src/parser/ocblocks.jl b/src/parser/ocblocks.jl
index c0d8bdeb..90a58f22 100644
--- a/src/parser/ocblocks.jl
+++ b/src/parser/ocblocks.jl
@@ -1,9 +1,10 @@
 """
 $(SIGNATURES)
 
-Find active blocks between an opening token (`otoken`) and a closing token `ctoken`. These can be
-nested (e.g. braces). Return the list of such blocks. If `deactivate` is `true`, all the tokens
-within the block will be marked as inactive (for further, separate processing).
+Find active blocks between an opening token (`otoken`) and a closing token
+`ctoken`. These can be nested (e.g. braces). Return the list of such blocks.
+If `deactivate` is `true`, all the tokens within the block will be marked as
+inactive (for further, separate processing).
 """
 function find_ocblocks(tokens::Vector{Token}, ocproto::OCProto;
                        inmath=false)::Tuple{Vector{OCBlock}, Vector{Token}}
@@ -37,8 +38,8 @@ function find_ocblocks(tokens::Vector{Token}, ocproto::OCProto;
             j = findfirst(cτ -> (cτ.name ∈ ocproto.ctok), tokens[i+1:end])
             # error if no closing token is found
             if isnothing(j)
-                throw(OCBlockError("I found the opening token '$(τ.name)' but not " *
-                                   "the corresponding closing token.",
+                throw(OCBlockError("I found the opening token '$(τ.name)' " *
+                                   "but not the corresponding closing token.",
                                    context(τ)))
             end
             j += i
@@ -57,9 +58,9 @@ end
 """
 $(SIGNATURES)
 
-Helper function to update the inbalance counter when looking for the closing token of a block with
-nesting. Adds 1 if the token corresponds to an opening token, removes 1 if it's a closing token and
-0 otherwise.
+Helper function to update the inbalance counter when looking for the closing
+token of a block with nesting. Adds 1 if the token corresponds to an opening
+token, removes 1 if it's a closing token and 0 otherwise.
 """
 function ocbalance(τ::Token, ocp::OCProto)::Int
     (τ.name == ocp.otok) && return 1
@@ -71,8 +72,8 @@ end
 """
 $(SIGNATURES)
 
-Convenience function to find all ocblocks e.g. such as `MD_OCBLOCKS`. Returns a vector of vectors
-of ocblocks.
+Convenience function to find all ocblocks e.g. such as `MD_OCBLOCKS`. Returns a
+vector of vectors of ocblocks.
 """
 function find_all_ocblocks(tokens::Vector{Token}, ocplist::Vector{OCProto}; inmath=false)
 
@@ -93,8 +94,8 @@ function find_all_ocblocks(tokens::Vector{Token}, ocplist::Vector{OCProto}; inma
     # CASE 1: block inside a larger escape block.
     #   this can happen if there is a code block in an escape block
     #   (see e.g. #151) or if there's indentation in a math block.
-    #   To fix this, we browse the escape blocks in backwards order and check if
-    #   there is any other block within it.
+    #   To fix this, we browse the escape blocks in backwards order and check
+    #   if there is any other block within it.
     i = length(ocbs_all)
     active = ones(Bool, i)
     all_heads = from.(ocbs_all)
@@ -128,9 +129,9 @@ end
 """
 $SIGNATURES
 
-Take a list of token and return those corresponding to special characters or html entities wrapped
-in `HTML_SPCH` types (will be left alone by the markdown conversion and be inserted as is in the
-HTML).
+Take a list of token and return those corresponding to special characters or
+html entities wrapped in `HTML_SPCH` types (will be left alone by the markdown
+conversion and be inserted as is in the HTML).
 """
 function find_special_chars(tokens::Vector{Token})
     spch = Vector{HTML_SPCH}()
diff --git a/src/parser/tokens.jl b/src/parser/tokens.jl
index 051d17ff..2cf64668 100644
--- a/src/parser/tokens.jl
+++ b/src/parser/tokens.jl
@@ -1,10 +1,11 @@
 """
 $(TYPEDEF)
 
-This is the supertype defining a section of the string into consideration which can be considered
-as a "block". For instance, `abc { ... } def` contains one braces block corresponding to the
-substring `{ ... }`. All subtypes of AbstractBlock must have a `ss` field corresponding to the
-substring associated to the block. See also [`Token`](@ref), [`OCBlock`](@ref).
+This is the supertype defining a section of the string into consideration which
+can be considered as a "block". For instance, `abc { ... } def` contains one
+braces block corresponding to the substring `{ ... }`. All subtypes of
+AbstractBlock must have a `ss` field corresponding to the substring associated
+to the block. See also [`Token`](@ref), [`OCBlock`](@ref).
 """
 abstract type AbstractBlock end
 
@@ -17,11 +18,12 @@ str(β::AbstractBlock)  = str(β.ss)
 """
 $(TYPEDEF)
 
-A token `τ::Token` denotes a part of the source string indicating a region that may need further
-processing. It is identified by a symbol `τ.name` (e.g.: `:MATH_ALIGN_OPEN`). Tokens are typically
-used in this code to identify delimiters of environments. For instance, `abc \$ ... \$ def`
-contains two tokens `:MATH_A` associated with the `\$` sign. Together they delimit here an inline
-math expression.
+A token `τ::Token` denotes a part of the source string indicating a region that
+may need further processing. It is identified by a symbol `τ.name` (e.g.:
+`:MATH_ALIGN_OPEN`). Tokens are typically used in this code to identify
+delimiters of environments. For instance, `abc \$ ... \$ def` contains two
+tokens `:MATH_A` associated with the `\$` sign. Together they delimit here an
+inline math expression.
 """
 struct Token <: AbstractBlock
     name::Symbol
@@ -35,8 +37,9 @@ to(β::Token) = ifelse(β.name == :EOS, from(β), to(β.ss))
 """
 $(TYPEDEF)
 
-A special block to wrap special characters like like a html entity and have it left unaffected
-by the Markdown to HTML transformation so that it can be  inserted "as is" in the HTML.
+A special block to wrap special characters like like a html entity and have it
+left unaffected by the Markdown to HTML transformation so that it can be
+inserted "as is" in the HTML.
 """
 struct HTML_SPCH <: AbstractBlock
     ss::SubString
@@ -48,9 +51,9 @@ HTML_SPCH(ss) = HTML_SPCH(ss, "")
 """
 $(TYPEDEF)
 
-Prototype for an open-close block (see [`OCBlock`](@ref)) with the symbol of the opening token
-(e.g. `:MATH_A`) and a corresponding list of closing tokens (e.g. `(:MATH_A,)`).
-See also their definitions in `parser/md_tokens.jl`.
+Prototype for an open-close block (see [`OCBlock`](@ref)) with the symbol of
+the opening token (e.g. `:MATH_A`) and a corresponding list of closing tokens
+(e.g. `(:MATH_A,)`). See also their definitions in `parser/md_tokens.jl`.
 """
 struct OCProto
     name::Symbol
@@ -63,9 +66,9 @@ end
 """
 $(TYPEDEF)
 
-Open-Close block, blocks that are defined by an opening `Token` and a closing `Token`, they may be
-nested. For instance braces block are formed of an opening `{` and a closing `}` and could be
-nested.
+Open-Close block, blocks that are defined by an opening `Token` and a closing
+`Token`, they may be nested. For instance braces block are formed of an opening
+`{` and a closing `}` and could be nested.
 """
 struct OCBlock <: AbstractBlock
     name::Symbol
@@ -77,8 +80,8 @@ end
 """
 $(SIGNATURES)
 
-Shorthand constructor to instantiate an `OCBlock` inferring the associated substring from the
-`ocpair` (since it's the substring in between the tokens).
+Shorthand constructor to instantiate an `OCBlock` inferring the associated
+substring from the `ocpair` (since it's the substring in between the tokens).
 """
 OCBlock(η::Symbol, ω::Pair{Token,Token}, nestable::Bool=false) =
     OCBlock(η, ω, subs(str(ω.first), from(ω.first), to(ω.second)))
@@ -103,8 +106,8 @@ ctok(ocb::OCBlock)::Token = ocb.ocpair.second
 """
 $(SIGNATURES)
 
-Convenience function to return the content of an open-close block (`OCBlock`), for instance the
-content of a `{...}` block would be `...`.
+Convenience function to return the content of an open-close block (`OCBlock`),
+for instance the content of a `{...}` block would be `...`.
 """
 function content(ocb::OCBlock)::SubString
     s = str(ocb.ss) # this does not allocate
@@ -126,8 +129,8 @@ FUNCTIONS / CONSTANTS THAT HELP DEFINE TOKENS
 """
 EOS
 
-Convenience symbol to mark the end of the string to parse (helps with corner cases where a token
-ends a document without being followed by a space).
+Convenience symbol to mark the end of the string to parse (helps with corner
+cases where a token ends a document without being followed by a space).
 """
 const EOS = '\0'
 
@@ -149,12 +152,13 @@ const NUM_CHAR   = ('1', '2', '3', '4', '5', '6', '7', '8', '9', '0')
 """
 $(SIGNATURES)
 
-Forward lookup checking if a sequence of characters matches `refstring` and is followed (or not
-followed if `isfollowed==false`) by a character out of a list of characters (`follow`).
-It returns
+Forward lookup checking if a sequence of characters matches `refstring` and is
+followed (or not followed if `isfollowed==false`) by a character out of a list
+of characters (`follow`). It returns
 
 1. a number of steps indicating the number of characters to check,
-2. whether there is an offset or not (if it is required to check a following character or not),
+2. whether there is an offset or not (if it is required to check a following
+character or not),
 3. a function that can be applied on a sequence of character.
 
 # Example
@@ -208,27 +212,28 @@ Check whether `c` is alpha numeric or in vector of character `ac`
 """
 $(SIGNATURES)
 
-Syntactic sugar for the incremental look case for which `steps=0` as well as the `offset`. This is
-a case where from a start character we lazily accept the next sequence of characters stopping as
-soon as a character fails to verify `λ(c)`.
-See also [`isexactly`](@ref).
+Syntactic sugar for the incremental look case for which `steps=0` as well as
+the `offset`. This is a case where from a start character we lazily accept the
+next sequence of characters stopping as soon as a character fails to verify
+`λ(c)`. See also [`isexactly`](@ref).
 """
 incrlook(λ::Function, validator=nothing) = (0, false, λ, validator)
 
 """
 $(SIGNATURES)
 
-In combination with `incrlook`, checks to see if we have something that looks like a @@div
-describing the opening of a div block. Triggering char is a first `@`.
+In combination with `incrlook`, checks to see if we have something that looks
+like a @@div describing the opening of a div block. Triggering char is a first
+`@`.
 """
-is_div_open(i::Int, c::Char) = (i == 1 && return c == '@'; return α(c, ('-','_')))
+is_div_open(i::Int, c::Char) = (i == 1 && return c == '@'; return α(c, ('-','_', NUM_CHAR...)))
 
 """
 $(SIGNATURES)
 
-In combination with `incrlook`, checks to see if we have something that looks like a triple
-backtick followed by a valid combination of letter defining a language. Triggering char is a
-first backtick.
+In combination with `incrlook`, checks to see if we have something that looks
+like a triple backtick followed by a valid combination of letter defining a
+language. Triggering char is a first backtick.
 """
 is_language() = incrlook(_is_language, _validate_language)
 
@@ -260,9 +265,10 @@ _validate_language2(stack::AS) = !isnothing(match(r"^`````[a-zA-Z]", stack))
 """
 $(SIGNATURES)
 
-In combination with `incrlook`, checks to see if we have something that looks like a html entity.
-Note that there can be fake matches, so this will need to be validated later on; if validated
-it will be treated as HTML; otherwise it will be shown as markdown. Triggerin char is a `&`.
+In combination with `incrlook`, checks to see if we have something that looks
+like a html entity. Note that there can be fake matches, so this will need to
+be validated later on; if validated it will be treated as HTML; otherwise it
+will be shown as markdown. Triggerin char is a `&`.
 """
 is_html_entity(i::Int, c::Char) = αη(c, ('#',';'))
 
@@ -280,8 +286,8 @@ end
 """
 TokenFinder
 
-Convenience type to define tokens. The Tuple comes from the output of functions such as
-[`isexactly`](@ref).
+Convenience type to define tokens. The Tuple comes from the output of functions
+such as [`isexactly`](@ref).
 """
 const TokenFinder = Pair{Tuple{Int,Bool,Function,Union{Bool,Nothing,Function}},Symbol}
 
@@ -289,8 +295,9 @@ const TokenFinder = Pair{Tuple{Int,Bool,Function,Union{Bool,Nothing,Function}},S
 """
 $(SIGNATURES)
 
-Go through a text left to right, one (valid) char at the time and keep track of sequences of chars
-that match specific tokens. The list of tokens found is returned.
+Go through a text left to right, one (valid) char at the time and keep track of
+sequences of chars that match specific tokens. The list of tokens found is
+returned.
 
 **Arguments**
 


Test patch:
diff --git a/test/parser/1-tokenize.jl b/test/parser/1-tokenize.jl
index f806f457..f0eeda44 100644
--- a/test/parser/1-tokenize.jl
+++ b/test/parser/1-tokenize.jl
@@ -40,6 +40,12 @@ isind(t) = t.name == :LR_INDENT && t.ss == "\n    "
     @test istok(t[17], :LXB_CLOSE, "}")
     @test islr(t[18])
     @test istok(t[19], :EOS, "\n")
+
+    # complement div with `-` or `_`
+    t = raw"""A @@d-a B@@ C""" |> tok
+    @test istok(t[1], :DIV_OPEN, "@@d-a")
+    t = raw"""A @@d-1 B@@ C""" |> tok
+    @test istok(t[1], :DIV_OPEN, "@@d-1")
 end
 
 @testset "P:1:ctok" begin