Re: [O] Help on org-export-filter-link-functions

2014-10-05 Thread John Kitchin
Rasmus ras...@gmx.us writes:

hmmm... the sometimes makes me nervous. I found even for links, this
only works sometimes. That doesn't seem reliable to me.

I think extending existing backends
(e.g. http://orgmode.org/manual/Advanced-configuration.html) is probably
more reliable for getting element properties, and approximately the same
amount of work.

I guess it just depends on how significantly you are modifying the
export, and what information you need to modify it. Filters are great
for simple wrapping and regexp based modifications. A derived backend is
better if you need reliable element properties, and a different format
than the default export.


 John Kitchin jkitc...@andrew.cmu.edu writes:

 I too am wondering if there is a defined way to get to the element
 properties within a filter function.

 qNo.  But sometimes you can recover it from the text-properties, if it
 is not a verb, (~·~, =·=).  Her's an example:

   (defun rasmus/get-org-headline-string-element  (headline backend info)
 Return the org element representation of a headline.
 (let ((prop-point (next-property-change 0 headline)))
   (and prop-point (plist-get (text-properties-at prop-point headline) 
 :parent

-- 
---
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu



Re: [O] Help on org-export-filter-link-functions

2014-10-05 Thread Rasmus
Hi John,

John Kitchin jkitc...@andrew.cmu.edu writes:

 hmmm... the sometimes makes me nervous. I found even for links, this
 only works sometimes. That doesn't seem reliable to me.

With headlines the case where it does not work is for verb-only
headings.  I guess that could occur more frequently with links, though
I have never done anything serious with links. q  

 I think extending existing backends
 (e.g. http://orgmode.org/manual/Advanced-configuration.html) is probably
 more reliable for getting element properties, and approximately the same
 amount of work.
 
In practice derived classes could be a lot of work.

There is also two hooks that run before processing, but you'd need to
be able to solve the issue with org syntax.  In practice this is not a
limitation as you can use snippets for whatever backend.

 I guess it just depends on how significantly you are modifying the
 export, and what information you need to modify it. Filters are great
 for simple wrapping and regexp based modifications. A derived backend is
 better if you need reliable element properties, and a different format
 than the default export.

Yeah.

–Rasmus

-- 
I almost cut my hair, it happened just the other day




Re: [O] Help on org-export-filter-link-functions

2014-10-04 Thread John Kitchin
Daimrod daim...@gmail.com writes:

Why don't you just define how the link should be exported in your link
definition?

for example:
https://github.com/jkitchin/jmax/blob/master/org/org-ref.org#the-links

You can see a link that is defined, with different export formats for
different backends.

I am intrigued by your function! It does not seem to work for all types
of links though, for example I tried on on some file links,
e.g. file:bib.bib, and [[file.bib]], but these fall in the (t data)
case. [[file:bib.bib][bibliography]] on the other hand gets handled and
you can access the element properties. 

I tried a similar approach on a table, but it did not work as I
expected. Apparently the next property change puts you in a table-cell,
rather than the parent table.

I too am wondering if there is a defined way to get to the element
properties within a filter function. For example, in this post
http://kitchingroup.cheme.cmu.edu/blog/2014/09/22/Showing-what-data-went-into-a-code-block-on-export/
I concocted a preprocess scheme to get a list of table names, and then a
filter function to put the names in the export on each table. It would
be much more elegant to get it directly from the table element somehow.




 Hi,

 I've wrote a simple filter to customize how links are exported in
 latex:

 #+BEGIN_SRC
 (defun dmd--latex-bib-link-filter (data backend info)
   Convert a bib link to a citation (e.g. bib:foo93 - \cite{foo93}).
   (let* ((beg (next-property-change 0 data))
  (link (if beg (get-text-property beg :parent data
 (cond ((and link
 (org-export-derived-backend-p backend 'latex)
 (string= (org-element-property :type link) bib))
(format \\cite{%s} (org-element-property :path link)))
   ((and link
 (org-export-derived-backend-p backend 'latex)
 (string= (org-element-property :type link) file)
 (string= (org-element-property :path link) ~/.bib.bib))
(format \\cite{%s} (org-element-property :search-option link)))
   (t data
 #+END_SRC

 And I was wondering whether there is an easier way to retrieve the org
 properties stored in the text properties of DATA.

 Best,

-- 
---
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu



Re: [O] Help on org-export-filter-link-functions

2014-10-04 Thread Rasmus
John Kitchin jkitc...@andrew.cmu.edu writes:

 I too am wondering if there is a defined way to get to the element
 properties within a filter function.

qNo.  But sometimes you can recover it from the text-properties, if it
is not a verb, (~·~, =·=).  Her's an example:

  (defun rasmus/get-org-headline-string-element  (headline backend info)
Return the org element representation of a headline.
(let ((prop-point (next-property-change 0 headline)))
  (and prop-point (plist-get (text-properties-at prop-point headline) 
:parent

-- 
And I faced endless streams of vendor-approved Ikea furniture. . .






[O] Help on org-export-filter-link-functions

2014-10-03 Thread Daimrod
Hi,

I've wrote a simple filter to customize how links are exported in
latex:
#+BEGIN_SRC
(defun dmd--latex-bib-link-filter (data backend info)
  Convert a bib link to a citation (e.g. bib:foo93 - \cite{foo93}).
  (let* ((beg (next-property-change 0 data))
 (link (if beg (get-text-property beg :parent data
(cond ((and link
(org-export-derived-backend-p backend 'latex)
(string= (org-element-property :type link) bib))
   (format \\cite{%s} (org-element-property :path link)))
  ((and link
(org-export-derived-backend-p backend 'latex)
(string= (org-element-property :type link) file)
(string= (org-element-property :path link) ~/.bib.bib))
   (format \\cite{%s} (org-element-property :search-option link)))
  (t data
#+END_SRC

And I was wondering whether there is an easier way to retrieve the org
properties stored in the text properties of DATA.

Best,

-- 
Daimrod/Greg


signature.asc
Description: PGP signature