Open elennaro opened 9 years ago
I second this feature.
Your first option is the best solution, it is a very small change in two files: Parser.java and Extensions.java to get a new extension HEADERSPACE
to require a space after Atx header prefix. The change passes all regression tests, so it is safe to use.
The change would not include this new extension in Extensions.ALL because that could break existing tests but it can also be done if someone has time on their hands. :)
Parser.java, replace one line in AtxHeading
rule:
public Rule AtxHeading() {
return Sequence(
AtxStart(),
replace this:
Optional(Sp()),
with:
(ext(HEADERSPACE) ? Spacechar() : EMPTY), Sp(),
OneOrMore(AtxInline(), addAsChild()),
wrapInAnchor(),
Optional(Sp(), ZeroOrMore('#'), Sp()),
Newline()
);
}
and in Extensions.java, change:
/**
* All available extensions excluding the SUPPRESS_... options and HEADERSPACE.
*/
static final int ALL = 0x0000FFFF;
to:
/**
* Requires a space char after Atx # header prefixes, so that #dasdsdaf is not a header.
*/
static final int HEADERSPACE = 0x800;
/**
* All available extensions excluding the SUPPRESS_... options and HEADERSPACE.
*/
static final int ALL = (0x0000FFFF & ~HEADERSPACE);
Closed by #181.
Now you can enable extension ATXHEADERSPACE to have the headers require a space.
In many situations we need to have #hashtags support. There is Two approaches: