Commit Graph
76 Commits
Author SHA1 Message Date
david parsons b52ec440d4 strip out MKD_STRICT as a single flag (convert it into a composite flag that turns off a whole bunch of extensions); use that flagbit to disable github checkbox items, strip out MKD_DLIST as a single flag (convert it into a mask of MKD_DLDISCOUNT|MKD_DLEXTRA, and rework pgm_options so that 'strict' and 'relaxed' apply only to emphasis and 'standard' is the flag that sets & clears flags to make it closer to the standard. Version 3 because I'm fucking with the published interface 2019-04-14 20:56:55 -07:00
david parsons 5bf1c6cfae add an external code block formatter to the markdown program 2019-04-12 08:25:02 -07:00
david parsons 1f90fde27f add an anchor format callback, plus add the -x option to the markdown program to squash toc anchors to (close to) github compatability 2019-02-18 20:54:05 -08:00
david parsons a12d7d7294 take a pass at github checklist items 2018-04-17 18:09:33 -07:00
david parsons e199a7aa9e if an unknown flag was in the middle of a comma-delimited flag
string (like -flatex,bogus,footnote), the markdown program
would incorrectly report the first flag as unknown (because set_flag
returned 0 on error, 1 on success and the strtok() of the flag string
had already replaced the commas up to that point with nulls.)

Change it so that set_flag returns null on successful processing and a
pointer to the offending flag on an unknown one.
2017-09-25 12:42:47 -07:00
david parsons 1c712469dd Make a new function (hoptusage()) to fabricate an uptodate usage: ...
message based on opts[] instead of relying on a hardcoded usage string.
2017-02-02 20:43:18 -08:00
david parsons 3e8386d071 Use gethopt() for options processing in markdown(8) & makepage(8) 2017-02-02 16:12:42 -08:00
david parsons 5a35cd041e Revert the previous commit that took unistd.h out 2017-02-02 14:44:55 -08:00
Mateusz Łoskot 473e53845d Remove redundant <unistd.h> header as unused 2017-02-02 23:35:22 +01:00
david parsons 9b792090ce Tweak the show_flags() function so that if it's called verbosely
it will show synonyms for named flags.   (Calling it verbosely is
done by the `V` option, which is overloaded for verbosity when listing
flags.)
2017-01-26 23:40:04 -08:00
Koen Punt 37659eb654 handle cleanup from the caller
instead of freeing the resource in mkd_xhtmlpage and mkd_dumptree, the mkd_cleanup now has to be explicitly called.
2015-10-25 15:46:53 +01:00
david parsons f9040ff400 Explicitly type main(), so c++ won't whine about it. 2014-11-01 20:56:31 -07:00
david parsons 8379b9bca3 In markdown, emit style blocks before table of contents html, and don't
forget to document this thing!
2012-08-07 11:12:44 -07:00
david parsons 59b4870573 Add -S (output style sections), -n (don't output generated text) options to the markdown test program. 2012-08-07 11:05:21 -07:00
david parsons 09945b7393 Create the gfm_string() method that does github flavoured markdown
on strings.
2012-05-31 22:37:58 -07:00
david parsons 66ac90e4b6 Add support for github flavoured markdown linebreaks (by adding new
functions that pad every input line with two spaces.)
2012-05-30 22:46:46 -07:00
david parsons 6c1737eacd don't forget to include tags.h 2012-01-23 22:05:24 -08:00
david parsons 094b09800e 1. In configure.inc, check for (and comment disapprovingly) if someone is inflicting clang on discount.
2. strip types off `main()`s so that stupid clang won't die.
2011-10-06 23:26:33 -07:00
david parsons 80c04f45e8 Change makepage so that I can feed it options
with `-Fxx`, `-fname`, or the environment variable
`MARKDOWN_FLAGS`; this means I needed to split the
options parsing code out of main.c into its own file
that can be included wherever.
2011-05-23 10:59:11 -07:00
david parsons 9cbe5f682a Don't use bitfields in the opts[] array; plan9 cc doesn't like it
(and I trust plan9's implementation, despite the prime movers
scampering off to Evil Inc, more than I trust gcc)
2011-05-05 15:09:27 -07:00
Alessandro Ghedini b668a06a2c fix typo, compatability -> compatibility 2011-03-16 20:29:53 +01:00
david parsons 3ea4599547 Cosmetic tweaks for the display output for -F? and -f? 2011-03-01 20:47:30 -08:00
david parsons 0be590709c Tweak table handling to hew more closely to the markdown extra implementation.
In particular, expand `\` escapes to include `:` and `|`, and follow how
the markdown extra dingus treats escaped line parts.
2011-03-01 10:02:13 -08:00
david parsons fa2581197e Add support for listing flags in the markdown program
by having the option `-f?` describe the named flags and `-F?`
describe the flag values.
2011-02-25 23:13:30 -08:00
david parsons b4ffe19529 Add the mkd_ref_prefix() function to set the prefix for footnotes from fn to some user-supplied value. 2011-02-18 22:16:13 -08:00
david parsons 2b6ea3799e create a typedef for the function argument to mkd_string_to_anchor, because some
compilers (and by some compilers, I mean "gcc") whine bitterly when you pass a
function argument with with a more specific pointer in place of a void*.   And if
I can't trust the compiler to emit sensible warnings, I'll just cast the damned
argument to a type that makes it stfu.

In addition, I needed to add prototypes for the html5 tag adder and the two
functions that spit out a list of the flags that the code was compiled with.
2011-01-29 11:00:54 -08:00
david parsons 5a019adc0c Add flags to enable/disable markdown extra footnotes 2011-01-13 12:02:12 -08:00
david parsons 517d7e408a We need to write a newline after mkd_flags_are() 2010-11-10 22:43:14 -08:00
david parsons 6922fdfe94 Add a couple of functions that write the current runtime configuration
(either a flags value (mkd_flags_are) or of an MMIOT (mkd_mmiot_flags))
to a FILE.    `markdown -VV` prints out the flags for now, and the
functions are there for other people to use as they desire.
2010-11-10 15:30:39 -08:00
david parsons ed7f0491e3 Strip out the compile-time definitions for definition lists, alpha lists, and div classes.
Everything optional should be runtime configurable now (and blockable with STRICT?)
2010-10-22 13:26:08 -07:00
David Parsons 1be9861064 Redo the superscript and relaxed emphasis flags into
NOSUPERSCRIPT and NORELAXED, so the default is to have them
turned on and you need to turn them off (or do STRICT) explicitly.
2010-10-21 21:10:24 -07:00
david parsons e78893be14 Add a config flag (MKD_NOSTRIKETHROUGH) to disable strikethrough.
Also add a test case file and `-f` options for the markdown command
line program.
2010-08-31 17:08:18 -07:00
David Parsons a4756602f1 Strip the --with-html5 configure.sh option out, make html5 support into a library function.
This involves reworking the blocktag[] array into a STRING(), and moving the entire
kit and kaboodle out into a separate file with a public initializer (mkd_prepare_tags),
definer (mkd_define_tag) sort (mkd_sort_tags, and lookup (mkd_search_tags) function.
The html5 tags are further removed into their own function (mkd_with_html5_tags) which
can be included when someone wishes to have html5 support.

Note that html5 support is library-wide;  once you call mkd_with_html5_tags, you're
stuck with them everywhere and can't back them out.   This might be revisited later,
2010-06-04 10:16:51 -07:00
David Parsons 9de2ee872a Mixup for the function name to write to the context data field 2010-01-29 18:24:22 -08:00
David Parsons 924cda8934 Clean up prototypes, and make a typedef for the callback
free funtion.
2010-01-29 18:19:58 -08:00
David Parsons c04ffa9cef add callbacks for editing urls and flags in [] and <> links. 2010-01-27 18:45:06 -08:00
David Parsons 94c0e700b4 1. Add a new flag (MKD_NOTABLES) to turn off the table extension.
2. Theme is /still/ broken for generating output files -- try to fix again.
3. Add more table test cases.
2009-08-02 10:32:02 -07:00
David Parsons e9c6511c64 1. Add More Plan9 + documentation patches from Josh Wood
2. Tweak the paragraph wrapping in `generate()` so that all
   paragraphs in a multiple-paragraph item/blockquote will
   be properly wrapped with `<p>`...`</p>` (or whatever is
   appropriate.)
3. Attempt to follow indentation better inside lists, so
   a list item with multiple paragraphs is parsed correctly
   when the second (& up) paragraphs are indented the same
   as the first paragraph.
2009-07-26 10:53:11 -07:00
David Parsons ebdd489ed7 1. Fix a bug in generate.c where MKD_NO_EXT was not being handled.
2. Add -fext to the options for the markdown program
3. `try`ify a bunch more of the test cases.
2009-06-17 14:30:43 -07:00
David Parsons ff8af93540 Version 1.4.3: Go back in again and hack away at linkyurl()
to try and better follow the horrid behavior of the reference
implementation.
2009-06-15 19:26:24 -07:00
David Parsons b039e3b1d9 Add two features suggested by Mike Schiraldi (mike@reddit.com);
1. "autolinks" -- expand unbracketed urls into links
      (flag MKD_AUTOLINK, -fautolink in the markdown program)
   2. "safe links" -- don't linkify footnotes where the link protocol
      isn't a well-known protocol (currently http: https:,ftp:,news:)
      (flag MKD_SAFELINK, -fsafelink in the markdown program)
2009-05-28 23:05:17 -07:00
David Parsons 8ca7a50e70 mkd_text() is now mkd_generateline(); the new
function `mkd_line()` formats a line into a string,
similarly to `mkd_toc()`, `mkd_xml()`, and so on.

There are a whole bunch of new public functions now,
so I'm pushing the version up to 1.4.0
2009-05-12 10:49:51 -07:00
David Parsons 4456632ae5 Roll up to compatability with MarkdownTest_1.0.3 (features not documented
in the language definition at Daringfireball) and add in compatability flags
to programmatically revert back to 1.0 compatability mode for testing
purposes.

The new markdown flag MKD_1_COMPAT turns on trailing space trimming of
the first line of codeblocks, and turns off support for implicit reference
links ([links] rather than [links][]);  it is enabled in the `markdown`
program with the flag -f1.0 (-F0x2000)
2009-02-27 22:47:03 -08:00
David Parsons 9397c0a5c7 Redo toc.c to add the new function mkd_toc(), which writes the
generate toc to a string.   Documented in `markdown.3`
and `mkd-functions.3`, requires a new file (`Csio.c`) that has
functions for writing to a Cstring, requires that some of the
internal functions in `generate.c` be exposed (and renaed to
`__mkd_`*function* to reduce namespace collisions.

The new functions in Csio (particularly `Csprintf()` should make
it easier to convert many of the other "we print to a `FILE*` and
you need to lump it" functions into a pair of "print to a string"
and "print to a file" functions.
2009-02-27 16:47:02 -08:00
David Parsons a59e83ec29 Add support for table-of-contents generation (code supplied by Jjgod Jiang)
and a function that generates a rudimentary xhmtl page from a markdown
document (idea from Tim Channon)
2008-09-26 11:39:32 -07:00
David Parsons b307bb9953 Add -f options to markdown(1) for enabling/disabling smartypants 2008-09-19 13:37:22 -07:00
David Parsons 1beefe2b28 Add the new option -s text ; use markdown(3) to process the text. 2008-09-18 12:51:46 -07:00
David Parsons 0120c3e3ae 1. Add the flag MKD_STRICT, which disables any configured superscripting
of A^B and non-emphasis on A_B.
2. markdown(1) now has the `strict` (enable `MKD_STRICT`) and `relax` (disable
   `MKD_STRICT`) flags.
3. truncate the input buffer at the end of every call to `text()` (corrects
   defect with --relaxed-emphasis where it was incorrectly looking back past
   the start of the input and triggering on the contents of the previous
   input (not reliably, so only detected when I put MKD_STRICT into the
   code.)
4. `markdown.1` manpage renamed to `markdown.1.in` and processed according
   to whether --relaxed-emphasis and/or --with-superscript are configured.
2008-09-03 11:36:07 -07:00
David Parsons ca7c57333c Revert "Up to version 1.2.8 ( --relaxed-emphasis, atx header pruning, -nohtml)"
(drop missing changes from pell?)

This reverts commit 7d414e7a23.
2008-08-22 07:51:14 -07:00
david parsons 7d414e7a23 Up to version 1.2.8 ( --relaxed-emphasis, atx header pruning, -nohtml) 2008-08-11 21:19:41 -07:00