Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Avanov committed Feb 18, 2014
2 parents fc7f764 + 32595eb commit d62d1bb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# General information about the project.
project = u'Plim'
copyright = u'2012, Maxim Avanov'
copyright = u'2014, Maxim Avanov'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
25 changes: 24 additions & 1 deletion docs/en/extensions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,29 @@ for parsing HTTP links present in a form of ``http_url > title``.
custom_preprocessor = preprocessor_factory(custom_parsers=CUSTOM_PARSERS)


The ``parse_http_link()`` function is defined according to the strict API.

Every parser accepts five input arguments:

1) ``indent_level`` - an indentation level of the current line. When the parser reaches a line
which indentation is lower or equal to ``indent_level``, it returns control to a top-level function.
2) ``current_line`` - a line which is being parsed. This is the line that has been matched by
``matched`` object at the previous parsing step.
3) ``matched`` - an instance of :class:`re.MatchObject` of the regex associated with the current parser.
4) ``source`` - an instance of an enumerated object returned by :func:`plim.lexer.enumerate_source`.
5) ``parsers`` - a tuple of 2-tuples of (parser_regex, parser_callable). Plim uses ``plim.lexer.STANDARD_PARSERS``
as a default collection of parsers that can be extended by third-party packages.

Every parser returns a 4-tuple of:

1) parsed_data - a string of successfully parsed data
2) tail_indent - an indentation level of the ``tail line``
3) tail_line - a line which indentation level (``tail_indent``) is lower or equal to
the input ``indent_level``.
4) ``source`` - an instance of enumerated object returned by :func:`plim.lexer.enumerate_source`
which represents the remaining (untouched) plim markup.


From now on, we can use ``custom_preprocessor`` in exactly the same manner as the standard
``plim.preprocessor``.

Expand All @@ -330,7 +353,7 @@ Let's create a plim document with extended syntax:
.. code-block:: plim
:linenos:

/ hamilton.html
/ hamilton.plim
---------------
html
head:title Alexander Hamilton
Expand Down
6 changes: 3 additions & 3 deletions plim/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@
#
# Every parser MUST accept five input arguments:
# 1) ``indent_level`` - an indentation level of the current line. When the parser reaches a line
# which indentation is lower or equal to `indent_level``, it returns control to a top-level function.
# which indentation is lower or equal to ``indent_level``, it returns control to a top-level function.
# 2) ``current_line`` - a line which is being parsed. This is the line that has been matched by
# ``matched`` object at the previous parsing step.
# 3) ``matched`` - an instance of re.MatchObject of the regex associated with the current parser.
# 3) ``matched`` - an instance of ``re.MatchObject`` of the regex associated with the current parser.
# 4) ``source`` - an instance of an enumerated object returned by :func:`enumerate_source`.
# 5) ``parsers`` - a tuple of 2-tuples of (parser_regex, parser_callable). Plim uses ``STANDARD_PARSERS``
# as a default collection of parsers that can be extended by third-party packages.
Expand All @@ -192,7 +192,7 @@
# 1) parsed_data - a string of successfully parsed data
# 2) tail_indent - an indentation level of the ``tail line``
# 3) tail_line - a line which indentation level (``tail_indent``) is lower or equal to
# the input `indent_level``.
# the input ``indent_level``.
# 4) ``source`` - an instance of enumerated object returned by :func:`enumerate_source`
# which represents the remaining (untouched) plim markup.
# ------------------------------
Expand Down

0 comments on commit d62d1bb

Please sign in to comment.