Commit Graph

409 Commits

Author SHA1 Message Date
Titus von der Malsburg 6779f8f424 Fix detection of latex fragments
* org-element.el (org-element-latex-fragment-parser):
* org.el (org-latex-regexps): Fix the detection of latex
  fragments.  Uses syntax tables to detect whitespaces and punctuation
  marks following the final $ sign.

In order to qualify as a math delimiter, the final $ sign of a LaTeX
fragment has to be followed by a whitespace or punctuation mark but the
regexp used in the previous code matched only a small number of
punctuation marks and therefore missed some latex fragments.
2015-05-09 09:36:53 +02:00
Nicolas Goaziou 7af8ce6cb3 org-element: Fix parsing bug in items
* lisp/org-element.el (org-element-item-parser): When contents are
  empty, do not find a zero-width paragraph within.
2015-05-07 23:45:41 +02:00
Nicolas Goaziou 2777b3fd4c org-element: Tolerate missing space after colon in keywords
* lisp/org-element.el (org-element--set-regexps):
(org-element--affiliated-re): Tolerate missing space after colon in
keywords.
2015-05-01 09:23:35 +02:00
Nicolas Goaziou eb77fed33f org-element: Fix parapraph parsing
* lisp/org-element.el (org-element--set-regexps): Refine
  `org-element-paragraph-separate'.
(org-element-paragraph-parser): Fix paragraph parsing when followed by
a dual keyword or an ill-formed latex environment.

* testing/lisp/test-org-element.el (test-org-element/paragraph-parser):
  Add tests.

Reported-by: Jacob Gerlach <jacobgerlach@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/97256>
2015-04-27 22:27:48 +02:00
Nicolas Goaziou 84e2e1e752 org-element: Keep ARCHIVE tag in headline tags
* lisp/org-element.el (org-element-headline-parser): Do not remove
  ARCHIVE tag.
(org-element-headline-interpreter): Apply change.

* testing/lisp/test-org-element.el (test-org-element/headline-archive-tag):
Update tests.

<http://permalink.gmane.org/gmane.emacs.orgmode/97141>
2015-04-24 14:28:17 +02:00
Nicolas Goaziou bf024eed8d org-element: Improve babel calls parsing
* lisp/org-element.el (org-element-babel-call-parser):
(org-element-inline-babel-call-parser): Parse call name, inside
header, arguments and end header.  Update docstring.

* testing/lisp/test-org-element.el (test-org-element/babel-call-parser):
(test-org-element/inline-babel-call-parser):
(test-org-element/babel-call-interpreter):
(test-org-element/inline-babel-call-interpreter): Add tests.
2015-04-21 11:54:22 +02:00
Nicolas Goaziou 0ab15904ec org-element: Fix "file" link :path
* lisp/org-element.el (org-element-link-parser): Fix :path value.
* testing/lisp/test-org-element.el (test-org-element/link-parser):
  Update tests.

:path now really contains the filename, not some truncated URI.
2015-04-20 12:35:41 +02:00
Nicolas Goaziou 1ba8413b0a org-element: Fix cache bug
* lisp/org-element.el (org-element--cache-for-removal): Be more
  careful when altering a properties drawer.

* testing/lisp/test-org-element.el (test-org-element/cache): Add test.
2015-04-06 00:37:49 +02:00
Nicolas Goaziou 789ddf155a org-element: Fix regexp
* lisp/org-element.el (org-element--cache-sensitive-re): Fix regexp.
2015-04-05 21:38:10 +02:00
Nicolas Goaziou fa70778a20 org-element: Remove `org-element-document-properties'
* lisp/org-element.el (org-element-document-properties): Remove
  variable.
(org-element-context): Ignore ex-"document keywords".

* testing/lisp/test-org-element.el (test-org-element/context): Remove
  no longer applicable tests.

Parsed keywords are no longer hard-coded and can be set per export
back-end.

As a consequence, `org-element-context' no longer returns objects in
"TITLE", "DATE" or "AUTHOR" keywords.  This makes sense as these
objects would only make sense during export, and only if the chosen
back-end actually uses them.
2015-04-05 13:48:28 +02:00
Nicolas Goaziou d4785381ec Change "\..." entities into "\_ "
* lisp/org-element.el (org-element--set-regexps):
(org-element-entity-parser): Update regexps.

* lisp/org-entities.el (org-entities): Modify syntax for space
  entities.

* lisp/org.el (org-fontify-entities): Update comment.

* lisp/org-clock.el (org-clocktable-indent-string): Apply syntax
  change.

* etc/ORG-NEWS (title): Update announce.

Use a less verbose syntax, which cannot interfere with file paths.
2015-03-22 21:45:00 +01:00
Nicolas Goaziou acebc4b0b5 org-element: Fix 22f942b481
* lisp/org-element.el (org-element-entity-parser): Fix regexp groups.
2015-03-22 10:09:29 +01:00
Nicolas Goaziou 22f942b481 Implement new entity family "\...."
* lisp/org-element.el (org-element--set-regexps):
(org-element-entity-parser): Update regexps for entities.

* lisp/org-entities.el (org-entities): Add new entities.

* lisp/org.el (org-fontify-entities): Add comment.

* etc/ORG-NEWS (title): Introduce new entities.

"\..." are used to insert an arbitrary number of spaces in various
back-ends.  In particular, this family can be used to introduce
leading spaces within table cells.

Also, unlike to other entities, these can be used mid-word, e.g.,

  wo\....rd

Curly brackets can still be added before a dot, e.g.,

  This is the end\...{}.
2015-03-22 09:55:20 +01:00
Nicolas Goaziou bcf6970369 org-element: `org-element-parse-secondary-string' accepts nil argument
* lisp/org-element.el (org-element-parse-secondary-string): Accept nil
  argument as a special case.

Reported-by: Rasmus <rasmus@gmx.us>
<http://permalink.gmane.org/gmane.emacs.orgmode/96234>
2015-03-21 09:43:45 +01:00
Nicolas Goaziou bf4a645cac org-element: Fix indentation removal with line breaks
* lisp/org-element.el (org-element-line-break-parser): Tiny
  refactoring.
(org-element-normalize-contents): Take into consideration line breaks
when removing common indentation.  Small refactoring.

* testing/lisp/test-org-element.el (test-org-element/normalize-contents):
  Add tests.
2015-03-07 01:58:28 +01:00
Nicolas Goaziou 40ef7af622 org-element: Elements can accept multiple secondary strings
* lisp/org-element.el (org-element-secondary-value-alist): Turn
  secondary properties into a list.
(org-element-secondary-p, org-element-map): Apply changes to variable
above.
2015-03-01 17:03:02 +01:00
Nicolas Goaziou 80bbf2440a org-element: Fix docstring
* lisp/org-element.el (org-element-set-contents): Fix docstring.
2015-02-27 11:53:00 +01:00
Nicolas Goaziou 7ebe87e2d5 org-element: Forbid footnote references in parsed keywords
* lisp/org-element.el (org-element-object-restrictions): Forbid
  footnote references in parsed keywords.

Inserting footnote references in parsed keywords (e.g., TITLE or
CAPTION) can lead to subtle bugs.  Indeed, it is impossible to know in
time if that particular footnote is going to be used in the output,
and, therefore, if it should count, e.g., in
`org-export-get-footnote-number'.
2015-02-15 21:56:57 +01:00
Nicolas Goaziou 13938b87c2 org-element: Faster inline footnotes parsing
* lisp/org-element.el (org-element--pair-square-table): New variable.
(org-element-footnote-reference-parser): Use new variable.
2015-02-15 13:33:25 +01:00
Nicolas Goaziou 650278f775 org-element: Interpret pseudo objects without declaration
* lisp/org-element.el (org-element-object-containers): New variable
(org-element-interpret-data): Remove optional argument.
(org-element--interpret-data-1): Remove optional argument.  Guess when
a given element or object has a pseudo type.

* lisp/ox-latex.el (org-latex-pseudo-objects): Remove variable.
(org-latex-table, org-latex--math-table): Apply signature change above.

* testing/lisp/test-org-element.el (test-org-element/interpret-data):
  Update test.
2015-02-09 12:04:38 +01:00
Nicolas Goaziou 7f66983184 org-element: Fix docstring
* lisp/org-element.el (org-element-copy): Fix docstring.
2015-02-09 10:57:39 +01:00
Nicolas Goaziou 70933a3dd6 org-element: Implement `org-element-copy'
* lisp/org-element.el (org-element-copy): New function.
* testing/lisp/test-org-element.el (test-org-element/copy): New test.
2015-02-09 10:07:34 +01:00
Nicolas Goaziou 55c0708bc4 org-element: Externalize docview links
* lisp/org-element.el (org-element-link-type-is-file): Remove.
(org-element-link-parser): Do not treat specially anymore "docview"
link type.

* testing/lisp/test-org-element.el (test-org-element/link-parser):
  Update test.

* lisp/org-docview.el (org-docview-export): Fix path.

"docview" is a custom link type handled in its own library.  There is
no reason to include it in core parser.
2015-02-03 23:00:21 +01:00
Nicolas Goaziou 8ff32ab112 Be more cautious when preserving visibility
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-list.el (org-list-swap-items):
(org-list-send-item): In order to preserve visibility of moved items
or elements, only consider inner overlays.

Reported-by: Michael Brand <michael.ch.brand@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/94320>
2015-01-30 00:20:01 +01:00
Nicolas Goaziou a1f54021c9 org-element: Remove :alt-title property for headlines
* lisp/org-element.el (org-element-headline-parser): Remove :alt-title.
* lisp/ox.el (org-export-get-alt-title): Check regular :ALT_TITLE
  property instead of :alt-title.

`:alt-title' is an export-specific property. As a consequence, it's
value doesn't need to be parsed at "org-element.el"'s level. There, it
is treated as a regular property : `ALT_TITLE'.

This also removes the last call to
`org-element-parse-secondary-string' from "org-element.el".
2015-01-28 11:41:39 +01:00
Nicolas Goaziou 98ee739e6d org-element: Avoid `org-element-parse-secondary-string'
* lisp/org-element.el (org-element-headline-parser,
  org-element-inlinetask-parser, org-element-item-parser,
  org-element--collect-affiliated-keywords): Use
  `org-element--parse-objects' instead of
  `org-element-parse-secondary-string' when parsing live objects in
  secondary strings.

`org-element-parse-secondary-string' parses a given string in
a temporary buffer, rendering buffer position related
properties (e.g., :begin) invalid.

Reported-by: John Kitchin <johnrkitchin@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/94397>
2015-01-27 22:25:15 +01:00
Nicolas Goaziou 6617e6dfa9 org-element: Tiny refactoring
* lisp/org-element.el (org-element-headline-interpreter,
  org-element-inlinetask-interpreter): Use format control string
  instead of calling `char-to-string'.
2015-01-27 17:49:22 +01:00
Nicolas Goaziou 96b02fa9a6 org-element: Tiny refactoring
* lisp/org-element.el (org-element-map): Reduce consing and improve
  readability at the price of a tiny code duplication.
2015-01-26 19:45:45 +01:00
Nicolas Goaziou cd6fa4c15e org-element: Optimize `org-element-map'
* lisp/org-element.el (org-element--parsed-properties-alist): New
  variable.
(org-element-map): Remove unnecessary funcalls.  Externalize some
computations in the variable above.
2015-01-25 12:32:03 +01:00
Nicolas Goaziou ec0706ea40 macro: Implement argument extracting and escaping functions
* lisp/org-macro.el (org-macro-escape-arguments,
  org-macro-extract-arguments): New functions.

* lisp/org-element.el (org-element-macro-parser): Use new function.

* testing/lisp/test-org-macro.el (test-org-macro/escape-arguments,
  test-org-macro/extract-arguments): New tests.
2015-01-21 00:27:24 +01:00
Nicolas Goaziou e4727803be org-element: Interpret diary timestamps
* lisp/org-element.el (org-element-timestamp-interpreter): Interpret
  diary timestamps.
2014-12-03 17:17:00 +01:00
Nicolas Goaziou 78773315ee Merge branch 'maint' 2014-11-18 19:46:44 +01:00
Nicolas Goaziou 4f31b68e8f org-element: Fix 'search failed ":"' error
* lisp/org-element.el (org-element-context): Fix 'search failed ":"'
  error when point is on a blank line after a keyword.

* testing/lisp/test-org-element.el (test-org-element/context): Add
  tests.
2014-11-18 19:44:46 +01:00
Nicolas Goaziou 1452b15235 org-element: Fix docstring
* lisp/org-element.el (org-element-lineage): Fix docstring.
2014-11-16 16:49:18 +01:00
Nicolas Goaziou 182d61fc8f org-element: Implement `org-element-lineage'
* lisp/org-element.el (org-element-lineage): New function.

* testing/lisp/test-org-element.el (test-org-element/lineage): New
  test.
2014-11-16 13:30:33 +01:00
Nicolas Goaziou 34bbb39454 Fix parser wrt to defcustom syntax related changes
* lisp/org-element.el (org-element-paragraph-separate,
  org-element--object-regexp): Turn defconst into defvar.
(org-element--set-regexps): Properly set previous variables.
(org-element-update-syntax): New function.

* lisp/org-list.el (org-plain-list-ordered-item-terminator,
  org-list-allow-alphabetical): Call new function whenever these
  variables are modified and Org is already loaded.

* lisp/org.el (org-add-link-type): Call new function since a new link
  type triggers a rebuild of syntax regexps, possibly invalidating
  cache in all Org buffers.

Reported-by: Christopher Dannheim <ch.dannheim@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/92487>
2014-11-10 00:08:44 +01:00
Nicolas Goaziou ae35b8c4ad org-element: Update property drawers parsing
* lisp/org-element.el (org-element--get-node-properties,
  org-element--get-time-properties): New functions.
(org-element-headline-parser, org-element-inlinetask-parser): Use new
functions.
(org-element-property-drawer-parser): Change signature.  Simplify
parsing.
drawer.
(org-element--current-element, org-element--next-mode): Property
drawers are located right after a headline or a planning element.

* testing/lisp/test-org-element.el (test-org-element/drawer-parser,
  test-org-element/node-property,
  test-org-element/property-drawer-interpreter): Update tests.
(test-org-element/property-drawer-parser): Add tests.
* testing/lisp/test-org.el (test-org/indent-line,
  test-org/indent-region, test-org/forward-paragraph,
  test-org/backward-paragraph): Update tests.
2014-10-28 14:23:51 +01:00
Nicolas Goaziou 3432681fbe Parsing and exporting special blocks preserve case
* lisp/org-element.el (org-element-special-block-parser):
* lisp/ox-latex.el (org-latex-special-block):
* lisp/ox-html.el (org-html-special-block):
* lisp/ox-man.el (org-man-special-block):
* lisp/ox-odt.el (org-odt-special-block):
* lisp/ox-texinfo.el (org-texinfo-special-block):
* contrib/lisp/ox-groff.el (org-groff-special-block): Preserve case.

* testing/lisp/test-org-element.el (test-org-element/special-block-parser):
  Add test.
2014-09-17 20:52:54 +02:00
Nicolas Goaziou 3f88821f01 org-element: Fix outdated comment 2014-09-13 22:34:15 +02:00
Nicolas Goaziou 97ae50fab3 org-element: Fix planning parsing
* lisp/org-element.el (org-element-planning-parser): Remove useless
  check.
(org-element--next-mode): Change signature.
(org-element--parse-elements, org-element--parse-to): Apply signature
change.

* testing/lisp/test-org-element.el (test-org-element/planning-parser):
  Add test.
2014-09-13 22:31:06 +02:00
Nicolas Goaziou 6eb9827d53 org-element: Fix cache error on empty drawers
* lisp/org-element.el (org-element--cache-for-removal): Handle case
  when greater element is totally empty.

Thanks to Malcolm Purvis for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/90639
2014-09-11 23:19:22 +02:00
Nicolas Goaziou e3369c07f0 Revert "Merge export and special blocks within back-ends"
This reverts commit fbc7097ffa.

Conflicts:
	lisp/ox-texinfo.el
2014-09-08 11:57:27 +02:00
Nicolas Goaziou 38d0eb64b0 org-element: Do not consider property drawers as robusts
* lisp/org-element.el (org-element--cache-for-removal): Do not
  consider property drawers as robusts: if contents are modified,
  remove the whole drawer from cache.
2014-09-02 21:18:40 +02:00
Nicolas Goaziou 2df0785fbd org-element: Complete 2125806
* lisp/org-element.el (org-element--parse-to): Do not bother checking
  for a planning line at the beginning of buffer.
2014-08-31 19:11:29 +02:00
Nicolas Goaziou 21258060ad org-element: Small optimization
* lisp/org-element.el (org-element--current-element): Only look after
  planning lines right after parsing a section.
(org-element--next-mode): New function.
(org-element--parse-elements, org-element--parse-to): Use new
function.
2014-08-31 16:31:59 +02:00
Nicolas Goaziou 539eac9211 org-element: Recognize planning info only right after a headline
* lisp/org.el (org-planning-line-re): New variable.  Renamed from
  `org-planning-or-clock-line-re'.

* lisp/org-element.el (org-element-paragraph-separate,
  org-element-headline-parser, org-element-inlinetask-parser, ,
  org-element--current-element): Use new variable.
(org-element-planning-parser): Check previous line before parsing
planning info.  When right after a headline, fallback to paragraph
parsing.

* testing/lisp/test-org-element.el (test-org-element/planning-parser):
  Add a test.  Update others.
(test-org-element/timestamp): Remove a test.
* testing/lisp/test-ox.el (test-org-export/handle-options): Update
  test.
2014-08-31 15:39:35 +02:00
Nicolas Goaziou d2643be6d8 Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2014-08-31 11:43:27 +02:00
Nicolas Goaziou 37bf0576f2 org-element: Make properties parsing more robust
* lisp/org-element.el (org-element-property-drawer-parser,
  org-element-node-property-parser): Ignore lines that are not node
  properties.
(org-element-node-property-interpreter): Allow nil properties.

* lisp/org.el (org-re-property): Fix regexp to match properties with
  empty values.

* testing/lisp/test-org-element.el (test-org-element/node-property):
  Add tests.

Thanks to Eike for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/90293
2014-08-31 11:10:56 +02:00
Nicolas Goaziou 3b4745d32a Merge branch 'maint'
Conflicts:
	lisp/org-element.el
2014-08-28 11:10:15 +02:00
Nicolas Goaziou 2e5b3dede1 org-element: Interpret headlines according to `org-odd-levels-only'
* lisp/org-element.el (org-element-headline-interpreter): Take into
  consideration `org-odd-levels-only' value.  Small refactoring.

* testing/lisp/test-org-element.el (test-org-element/headline-interpreter):
  Add test.
2014-08-28 11:07:24 +02:00