Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown filter #558

Merged
merged 6 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,29 @@ jobs:
- run: CXX=clang++-8 CC=clang-8 ./sanity-check.sh
- run: ./config-opt && make -C build -j2

tests:
working_directory: ~/GNUAspell/aspell
parallelism: 1
docker:
- image: circleci/buildpack-deps:19.04
steps:
# Machine Setup
- checkout
#
- run: sudo apt-get -y update
- run: sudo apt-get -y install make autopoint texinfo libtool intltool bzip2 gettext libipc-system-simple-perl
- run: sudo apt-get -y purge aspell
#
- run: ./autogen
- run: make -j2 -C test

workflows:
version: 2
sanity_check:
jobs:
- build_jessie
- build_18_04
- build_19_04
tests:
jobs:
- tests
9 changes: 8 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ optfiles = \
modules/filter/email-filter.info\
modules/filter/tex-filter.info\
modules/filter/sgml-filter.info\
modules/filter/markdown-filter.info\
modules/filter/html-filter.info\
modules/filter/context-filter.info\
modules/filter/nroff-filter.info\
Expand All @@ -175,6 +176,7 @@ optfiles = \
fltfiles = \
modules/filter/modes/html.amf \
modules/filter/modes/sgml.amf \
modules/filter/modes/markdown.amf \
modules/filter/modes/tex.amf \
modules/filter/modes/email.amf \
modules/filter/modes/ccpp.amf \
Expand All @@ -196,6 +198,7 @@ libaspell_la_SOURCES +=\
modules/filter/email.cpp\
modules/filter/tex.cpp\
modules/filter/sgml.cpp\
modules/filter/markdown.cpp\
modules/filter/context.cpp\
modules/filter/nroff.cpp\
modules/filter/texinfo.cpp
Expand All @@ -208,7 +211,7 @@ filter_ldflags = -module -avoid-version
### Add name of filter library containing your filter. Name always
### must look like lib<filtername>-filter.la see development manual
filter_LTLIBRARIES = email-filter.la tex-filter.la\
sgml-filter.la context-filter.la\
sgml-filter.la markdown-filter.la context-filter.la\
nroff-filter.la texinfo-filter.la

email_filter_la_SOURCES = modules/filter/email.cpp
Expand All @@ -223,6 +226,10 @@ sgml_filter_la_SOURCES = modules/filter/sgml.cpp
sgml_filter_la_LIBADD = libaspell.la
sgml_filter_la_LDFLAGS = ${filter_ldflags}

markdown_filter_la_SOURCES = modules/filter/markdown.cpp
markdown_filter_la_LIBADD = libaspell.la
markdown_filter_la_LDFLAGS = ${filter_ldflags}

context_filter_la_SOURCES = modules/filter/context.cpp
context_filter_la_LIBADD = libaspell.la
context_filter_la_LDFLAGS = ${filter_ldflags}
Expand Down
7 changes: 5 additions & 2 deletions auto/mk-src.in
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,11 @@ class: document checker
method: process

desc => Process a string.
The string passed in should only be split on
white space characters. Furthermore, between
The document is expected to be passed in one or more
lines at a time. Splitting the document on
white space characters instead of new lines is
permissible but some filters which are line based
may give incorrect results. Furthermore, between
calls to reset, each string should be passed
in exactly once and in the order they appeared
in the document. Passing in strings out of
Expand Down
2 changes: 1 addition & 1 deletion config-debug
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ mkdir -p build
cd build
../configure --enable-maintainer-mode \
--disable-shared --disable-pspell-compatibility\
--prefix="`pwd`/../inst" CFLAGS='-g -Wall' CXXFLAGS='-g -Wall' "$@"
--prefix="`pwd`/../inst" CFLAGS='-g -Wall -Wno-unused' CXXFLAGS='-g -Wall -Wno-unused' "$@"
59 changes: 59 additions & 0 deletions manual/aspell.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,55 @@ The @option{html} filter is like the SGML Filter Mode but specialized for
HTML. By default, 'script' and 'style' are members of the skip list in
HTML mode.

@subsubsection Markdown Filter

The @option{markdown} filter/mode skips over code and links in Markdown
documents. The mode also handles HTML via the @option{html} filter
which runs after the Markdown filer.

Properly parsing Markdown requires reading the entire document in at
once, which doesn't fit well into the existing filter framework so the
filter parses the document a line at a time and makes a best guess
when a line ends without enough information to correctly parse a a
tag. For example in the following:
@example
`This looks like inline code

But it's not, becuase the of the blank line.
@end example
the first line will be incorrectly skipped.

It supports the following two options that may be useful:

@table @b

@item markdown-multiline-tags
Enables or disables support for HTML tags that might span multiple
lines (outside of HTML blocks). Enabled by default (to disable from
the command line use @samp{--dont-markdown-multiline-tags}).

@item markdown-skip-ref-labels
Boolean option the controls if ref lables are skipped. For when this
option is enabled @samp{[ref]} will be skipped over in:
@example
[link][ref]

[ref]: #c2 "Chapter 2"
@end example
Enabled by default (to disable from
the command line use @samp{--dont-markdown-skip-ref-labels}).

@end table

The Markdown filter also supports the @option{markdown-raw-start-tags}
and @option{markdown-block-start-tags} list options. These options
are a list of HTML tags that start an HTML block. If the block starts
with a tag listed in @option{markdown-raw-start-tags} then the block
ends with the corresponding closing tag. If the block starts with a
tag listed in @option{markdown-block-start-tags} then the block ends
with a blank line. The defaults for these two options are taken from
the CommonMark spec (version 0.29, 2019-04-06).

@subsubsection @TeX{}/LaTeX Filter

The @option{tex} (all lowercase) filter mode skips over @TeX{}
Expand Down Expand Up @@ -4272,7 +4321,17 @@ a C++ program.
@heading Changes from 0.60.7 to 0.68.8 (???)
@itemize @bullet
@item
Add Markdown filter.
@item
Implement @code{aspell filter} command.
@item
Remove unused @option{sug-edit-dist} option.
@item
In order to work with the new Markdown filter
@code{AspellDocumentChecker} now expects the document a line at a
time. If the document is split on white space characters instead,
nothing will break, but new filters such as the Markdown filter may
give incorrect results.
@end itemize

@heading Changes from 0.60.6.1 to 0.60.7 (July 29, 2019)
Expand Down
97 changes: 97 additions & 0 deletions modules/filter/markdown-filter.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# SGML filter option file

LIB-FILE markdown-filter

#This Filter is usable with the following version(s) of Aspell
ASPELL >=0.60

DESCRIPTION filter for Markdown/CommonMark documents

STATIC filter

OPTION skip-ref-labels
TYPE bool
DESCRIPTION skip link labels in link reference definitions
DEFAULT true
ENDOPTION

OPTION multiline-tags
TYPE bool
DESCRIPTION support tags that span multiple lines outside of HTML blocks
DEFAULT true
ENDOPTION

OPTION raw-start-tags
TYPE list
DESCRIPTION html tags that start a HTML block that allows blank lines
DEFAULT script
DEFAULT pre
DEFAULT style
ENDOPTION

OPTION block-start-tags
TYPE list
DESCRIPTION html tags that start a HTML block that end with a blank line
DEFAULT address
DEFAULT article
DEFAULT aside
DEFAULT base
DEFAULT basefont
DEFAULT blockquote
DEFAULT body
DEFAULT caption
DEFAULT center
DEFAULT col
DEFAULT colgroup
DEFAULT dd
DEFAULT details
DEFAULT dialog
DEFAULT dir
DEFAULT div
DEFAULT dl
DEFAULT dt
DEFAULT fieldset
DEFAULT figcaption
DEFAULT figure
DEFAULT footer
DEFAULT form
DEFAULT frame
DEFAULT frameset
DEFAULT h1
DEFAULT h2
DEFAULT h3
DEFAULT h4
DEFAULT h5
DEFAULT h6
DEFAULT head
DEFAULT header
DEFAULT hr
DEFAULT html
DEFAULT iframe
DEFAULT legend
DEFAULT li
DEFAULT link
DEFAULT main
DEFAULT menu
DEFAULT menuitem
DEFAULT nav
DEFAULT noframes
DEFAULT ol
DEFAULT optgroup
DEFAULT option
DEFAULT p
DEFAULT param
DEFAULT section
DEFAULT source
DEFAULT summary
DEFAULT table
DEFAULT tbody
DEFAULT td
DEFAULT tfoot
DEFAULT th
DEFAULT thead
DEFAULT title
DEFAULT tr
DEFAULT track
DEFAULT ul
ENDOPTION
Loading