* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-16 10:16 ` Nicolas Goaziou
@ 2014-03-16 11:18 ` Marcin Borkowski
2014-03-16 11:57 ` Nicolas Goaziou
2014-03-17 16:31 ` Marcin Borkowski
2014-11-25 21:25 ` Marcin Borkowski
2 siblings, 1 reply; 19+ messages in thread
From: Marcin Borkowski @ 2014-03-16 11:18 UTC (permalink / raw)
To: Org-mode mailing list
Dnia 2014-03-16, o godz. 11:16:03
Nicolas Goaziou <n.goaziou@gmail.com> napisał(a):
> Hello,
>
> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>
> > OK, so I did some research, and I found out that "special blocks"
> > are probably the best idea. So, items with checkboxes
> > whose :parent is a special block like "MCT" or "SCT" could behave
> > accordingly. Still, I can't see in the docs any mentions about
> > possible properties of special blocks. Is it possible to make an
> > exporter so that I could say
> >
> > #+BEGIN_ANSWER :lines 2
> > This is an answer.
> > #+END_ANSWER
> >
> > so that I could use the property :lines in org-special-block? I
> > don't want to utilize #+ATTR_LATEX, since I'm aiming at extensions
> > to both LaTeX and HTML exporters recognizing this thing.
>
> What about #+attr_yourbackend ? E.g.,
>
> #+attr_yourbackend: :type mct
> - answer a
> - answer b
> - answer c
>
> or,
>
> #+attr_yourbackend: :lines 2
> #+begin_answer
> This is an answer.
> #+end_answer
I thought about it. But, as I said, I'm going to have two backends,
one for LaTeX, one for HTML. WOuld it be possible to have e.g.
#+ATTR_TEST
working for both?
(Anyway, options after #+BEGIN_MYBLOCK would be a bit nicer, since the
user would not have to type /that/ much.)
> Another, more advanced option, is to use a parse tree filter to create
> pseudo-types, i.e., element or object types that don't exist in
> regular Org syntax. See `math-block' type in "ox-latex.el", in
> particular `org-latex-math-block-tree-filter'.
Thanks, I'll look into this!
I tried to look for math-block in ox-latex.el, but did not find it. I
have Org-mode from Elpa, org-version gives:
Org-mode version 8.2.5f
(8.2.5f-elpa @ /home/marcin/.emacs.d/elpa/org-20140116/)
Should I upgrade?
> Regards,
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-16 11:18 ` Marcin Borkowski
@ 2014-03-16 11:57 ` Nicolas Goaziou
2014-03-16 13:33 ` Marcin Borkowski
2014-03-16 16:05 ` Aaron Ecay
0 siblings, 2 replies; 19+ messages in thread
From: Nicolas Goaziou @ 2014-03-16 11:57 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Org-mode mailing list
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> I thought about it. But, as I said, I'm going to have two backends,
> one for LaTeX, one for HTML. WOuld it be possible to have e.g.
>
> #+ATTR_TEST
>
> working for both?
Of course. You decide, at the backend level, what attributes are read.
For example, "ox-beamer.el" reads both "ATTR_LATEX" and "ATTR_BEAMER",
when it makes sense.
> (Anyway, options after #+BEGIN_MYBLOCK would be a bit nicer, since the
> user would not have to type /that/ much.)
This is backend specific data. It would not be nice to hide that fact.
Options on the same line as the block opening string should be reserved
for backend agnostic data. There is none for special blocks at the
moment.
> I tried to look for math-block in ox-latex.el, but did not find it. I
> have Org-mode from Elpa, org-version gives:
>
> Org-mode version 8.2.5f
> (8.2.5f-elpa @ /home/marcin/.emacs.d/elpa/org-20140116/)
>
> Should I upgrade?
IIRC the feature is in master, not in maint, so upgrading through ELPA
won't help. But you can browse the repository online.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-16 11:57 ` Nicolas Goaziou
@ 2014-03-16 13:33 ` Marcin Borkowski
2014-03-16 14:12 ` Nicolas Goaziou
2014-03-16 16:05 ` Aaron Ecay
1 sibling, 1 reply; 19+ messages in thread
From: Marcin Borkowski @ 2014-03-16 13:33 UTC (permalink / raw)
To: emacs-orgmode
Dnia 2014-03-16, o godz. 12:57:49
Nicolas Goaziou <n.goaziou@gmail.com> napisał(a):
> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>
> > I thought about it. But, as I said, I'm going to have two backends,
> > one for LaTeX, one for HTML. WOuld it be possible to have e.g.
> >
> > #+ATTR_TEST
> >
> > working for both?
>
> Of course. You decide, at the backend level, what attributes are read.
> For example, "ox-beamer.el" reads both "ATTR_LATEX" and "ATTR_BEAMER",
> when it makes sense.
Thanks again!
The more I look into docs and sources of the exporter(s), the less
intimidated I feel. (Still, there are quite a few mysteries there,
but I seem to get the basic ideas.) And the more I look at all this
stuff, the more awe I feel...
So basically I can attach #+ATTR_WHATEVER attributes also to lists,
paragraphs and other elements? Even list items? (This would mean
that I could mark the "correct" answer using that syntax - but I think
this would be too verbose. I can't see any harm in abusing checkboxes
for that, though I [[http://xkcd.com/292/][might be mistaken]];))
> > (Anyway, options after #+BEGIN_MYBLOCK would be a bit nicer, since
> > the user would not have to type /that/ much.)
>
> This is backend specific data. It would not be nice to hide that fact.
>
> Options on the same line as the block opening string should be
> reserved for backend agnostic data. There is none for special blocks
> at the moment.
I see. (OTOH, special blocks get translated to LaTeX environments and
<div>s in HTML, and are ignored in some other backends - but maybe
that's correct and I just was misled by this. Never mind.)
> > I tried to look for math-block in ox-latex.el, but did not find
> > it. I have Org-mode from Elpa, org-version gives:
> >
> > Org-mode version 8.2.5f
> > (8.2.5f-elpa @ /home/marcin/.emacs.d/elpa/org-20140116/)
> >
> > Should I upgrade?
>
> IIRC the feature is in master, not in maint, so upgrading through ELPA
> won't help. But you can browse the repository online.
I see. Well, I guess I'll go with the attributes (especially that I
won't need special blocks for that anyway); in some Spare Time™ I'll
update my git clone of Org and look at it.
> Regards,
Thanks a lot!
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
--
Marcin Borkowski
room B3-46, phone no +48 61 829 5375
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-16 13:33 ` Marcin Borkowski
@ 2014-03-16 14:12 ` Nicolas Goaziou
2014-03-17 15:43 ` Marcin Borkowski
0 siblings, 1 reply; 19+ messages in thread
From: Nicolas Goaziou @ 2014-03-16 14:12 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: emacs-orgmode
Marcin Borkowski <mbork@amu.edu.pl> writes:
> So basically I can attach #+ATTR_WHATEVER attributes also to lists,
> paragraphs and other elements? Even list items? (This would mean
> that I could mark the "correct" answer using that syntax - but I think
> this would be too verbose. I can't see any harm in abusing checkboxes
> for that, though I [[http://xkcd.com/292/][might be mistaken]];))
You can attach attributes (which is a subset of "affiliated keywords"
category) to any element excepted clock, headline, inlinetask, item,
planning, node-property, section and table-row types.
So, plain lists can have attributes, but not items. There are
workarounds, though. For example, you can use an export snippet at the
beginning of the item to mark the correct answer. Hence, assuming "qcm"
is the name of your backend, you could use:
#+attr_qcm: :type mct
- answer a
- @@qcm:correct@@ answer b
- answer c
"ox-beamer.el" uses it to specify action overlays item wise. See
`org-beamer-item' for an example.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-16 14:12 ` Nicolas Goaziou
@ 2014-03-17 15:43 ` Marcin Borkowski
0 siblings, 0 replies; 19+ messages in thread
From: Marcin Borkowski @ 2014-03-17 15:43 UTC (permalink / raw)
To: emacs-orgmode
Dnia 2014-03-16, o godz. 15:12:46
Nicolas Goaziou <n.goaziou@gmail.com> napisał(a):
> Marcin Borkowski <mbork@amu.edu.pl> writes:
>
> > So basically I can attach #+ATTR_WHATEVER attributes also to lists,
> > paragraphs and other elements? Even list items? (This would mean
> > that I could mark the "correct" answer using that syntax - but I
> > think this would be too verbose. I can't see any harm in abusing
> > checkboxes for that, though I [[http://xkcd.com/292/][might be
> > mistaken]];))
>
> You can attach attributes (which is a subset of "affiliated keywords"
> category) to any element excepted clock, headline, inlinetask, item,
> planning, node-property, section and table-row types.
I see.
> So, plain lists can have attributes, but not items. There are
> workarounds, though. For example, you can use an export snippet at the
> beginning of the item to mark the correct answer. Hence, assuming
> "qcm" is the name of your backend, you could use:
>
> #+attr_qcm: :type mct
> - answer a
> - @@qcm:correct@@ answer b
> - answer c
>
> "ox-beamer.el" uses it to specify action overlays item wise. See
> `org-beamer-item' for an example.
Interesting, though I think I'll stick with checkboxes - esepcially
that it is easy for the user/author to mark them on and off.
> Regards,
Thanks again!
--
Marcin Borkowski
room B3-46, phone no +48 61 829 5375
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-16 11:57 ` Nicolas Goaziou
2014-03-16 13:33 ` Marcin Borkowski
@ 2014-03-16 16:05 ` Aaron Ecay
1 sibling, 0 replies; 19+ messages in thread
From: Aaron Ecay @ 2014-03-16 16:05 UTC (permalink / raw)
To: Nicolas Goaziou, Marcin Borkowski; +Cc: Org-mode mailing list
Hi Marcin and Nicolas,
2014ko martxoak 16an, Nicolas Goaziou-ek idatzi zuen:
>
> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>
>> I thought about it. But, as I said, I'm going to have two backends,
>> one for LaTeX, one for HTML. WOuld it be possible to have e.g.
>>
>> #+ATTR_TEST
>>
>> working for both?
>
> Of course. You decide, at the backend level, what attributes are read.
> For example, "ox-beamer.el" reads both "ATTR_LATEX" and "ATTR_BEAMER",
> when it makes sense.
>
>> (Anyway, options after #+BEGIN_MYBLOCK would be a bit nicer, since the
>> user would not have to type /that/ much.)
>
> This is backend specific data. It would not be nice to hide that fact.
I haven’t followed the thread closely, but it sounds like Marcin may be
considering both LaTeX and HTML output, which makes this not exactly
specific to a single backend.
>
> Options on the same line as the block opening string should be reserved
> for backend agnostic data. There is none for special blocks at the
> moment.
There is indeed no support for options on the #+begin_foo line. But
special blocks, and indeed any other element, can take a #+header: line.
It can fulfill the same functions as an #+attr_foo: line, but is seen by
all backends.
HTH,
--
Aaron Ecay
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-16 10:16 ` Nicolas Goaziou
2014-03-16 11:18 ` Marcin Borkowski
@ 2014-03-17 16:31 ` Marcin Borkowski
2014-03-22 11:23 ` Nicolas Goaziou
2014-11-25 21:25 ` Marcin Borkowski
2 siblings, 1 reply; 19+ messages in thread
From: Marcin Borkowski @ 2014-03-17 16:31 UTC (permalink / raw)
To: Org-mode mailing list
Dnia 2014-03-16, o godz. 11:16:03
Nicolas Goaziou <n.goaziou@gmail.com> napisał(a):
> Another, more advanced option, is to use a parse tree filter to create
> pseudo-types, i.e., element or object types that don't exist in
> regular Org syntax. See `math-block' type in "ox-latex.el", in
> particular `org-latex-math-block-tree-filter'.
I started to wonder and came to the conclusion that this might be
interesting for my "cloze" idea (with syntax as in one of my previous
messages). However, I can't really understand what is going on here.
It seems to me that the key function is
org-latex--wrap-latex-math-block; it is, however, a bit long and I'm a
bit afraid of studying it (and don't have enough time today for that
anyway). What would you suggest for grokking the idea of
"pseudo-objects"? In particular:
- How do they get parsed? What portions of the source should I read
to understand that?
- Would it be a good idea to instrument one (or more) functions for
edebug to get the idea of what's going on there?
- How risky is it to use Org from master in day-to-day usage? Do
people (other than the devs) do this on a regular basis? Is coming
back to maint as simple as checking out another branch from the git
repo?
> Regards,
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-17 16:31 ` Marcin Borkowski
@ 2014-03-22 11:23 ` Nicolas Goaziou
0 siblings, 0 replies; 19+ messages in thread
From: Nicolas Goaziou @ 2014-03-22 11:23 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Org-mode mailing list
Hello,
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> I started to wonder and came to the conclusion that this might be
> interesting for my "cloze" idea (with syntax as in one of my previous
> messages). However, I can't really understand what is going on here.
> It seems to me that the key function is
> org-latex--wrap-latex-math-block; it is, however, a bit long and I'm a
> bit afraid of studying it (and don't have enough time today for that
> anyway). What would you suggest for grokking the idea of
> "pseudo-objects"? In particular:
>
> - How do they get parsed? What portions of the source should I read
> to understand that?
They are not parsed.
You create a new parsed object or element out of thin air, or alter
existing markup under certain conditions, and insert it in the parse
tree before it gets interpreted by an export back-end.
> - Would it be a good idea to instrument one (or more) functions for
> edebug to get the idea of what's going on there?
Edebug will help only if you have a good mental representation of the
parse tree (or at least a function to display it when it is short
enough), but it is a valuable tool to understand what happens.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-03-16 10:16 ` Nicolas Goaziou
2014-03-16 11:18 ` Marcin Borkowski
2014-03-17 16:31 ` Marcin Borkowski
@ 2014-11-25 21:25 ` Marcin Borkowski
2014-11-25 21:46 ` Marcin Borkowski
` (2 more replies)
2 siblings, 3 replies; 19+ messages in thread
From: Marcin Borkowski @ 2014-11-25 21:25 UTC (permalink / raw)
To: emacs-orgmode
Hello there,
this is close to necromancy, but let me revive this old thread.
On 2014-03-16, at 11:16, Nicolas Goaziou wrote:
> Another, more advanced option, is to use a parse tree filter to create
> pseudo-types, i.e., element or object types that don't exist in regular
> Org syntax. See `math-block' type in "ox-latex.el", in particular
> `org-latex-math-block-tree-filter'.
Now that I actually started work on my exporter, I'd like to investigate
this further. The thing is, I'm not sure where to start. First of all,
I have a bit old Org-mode (without latex-math-blocks); I guess I'll just
have to update it (I'll try to do an Elpa update in a minute). But my
question is:
1. Is it a good idea to instrument `org-latex--wrap-latex-math-block'
for Edebug to learn what's happening?
2. Is there any other (possibly simpler) instance of pseudo-blocks I
could study? It seems to me (from the docstring) that latex-math-blocks
are a bit tricky; what I'm interested in is more like creating a new
element similar to e.g. italics.
(Reagrdless of the answer, I'll try with Edebug, but I'm a bit afraid
that I won't understand what's going on).
Also, if (when?) I "get it", I'm going to describe the process of adding
a pseudo-object somewhere (I consider my blog, or maybe I could upload
it to Worg?), so that other people can learn it easier. But for now, I
might need help.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-11-25 21:25 ` Marcin Borkowski
@ 2014-11-25 21:46 ` Marcin Borkowski
2014-11-26 2:46 ` John Kitchin
2014-11-26 11:59 ` Nicolas Goaziou
2 siblings, 0 replies; 19+ messages in thread
From: Marcin Borkowski @ 2014-11-25 21:46 UTC (permalink / raw)
To: emacs-orgmode
On 2014-11-25, at 22:25, Marcin Borkowski wrote:
> Now that I actually started work on my exporter, I'd like to investigate
> this further. The thing is, I'm not sure where to start. First of all,
> I have a bit old Org-mode (without latex-math-blocks); I guess I'll just
> have to update it (I'll try to do an Elpa update in a minute). But my
Just checked, latex-math-block is in git, but in Elpa. I don't have
enough time now to install Org from Git (though this may be the final
motivation for me to do so), so I'd especially welcome any answers to
item 2 below.
> question is:
>
> 1. Is it a good idea to instrument `org-latex--wrap-latex-math-block'
> for Edebug to learn what's happening?
>
> 2. Is there any other (possibly simpler) instance of pseudo-blocks I
> could study? It seems to me (from the docstring) that latex-math-blocks
> are a bit tricky; what I'm interested in is more like creating a new
> element similar to e.g. italics.
TIA,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-11-25 21:25 ` Marcin Borkowski
2014-11-25 21:46 ` Marcin Borkowski
@ 2014-11-26 2:46 ` John Kitchin
2014-11-26 14:23 ` John Kitchin
2014-11-26 11:59 ` Nicolas Goaziou
2 siblings, 1 reply; 19+ messages in thread
From: John Kitchin @ 2014-11-26 2:46 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: emacs-orgmode
Could you remind us of what you are trying to do? It seems like you may
not necessarily need custom elements (although that could be
useful). For example, you can put a lot of information in properties of
a headline.
You might be interested in this:
http://kitchingroup.cheme.cmu.edu/blog/2014/11/23/Machine-gradable-quizzes-in-emacs+org-modex/
I recently used this is in my class of 58 students (who all used emacs
and org-mode to take a quiz!).
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> Hello there,
>
> this is close to necromancy, but let me revive this old thread.
>
> On 2014-03-16, at 11:16, Nicolas Goaziou wrote:
>
>> Another, more advanced option, is to use a parse tree filter to create
>> pseudo-types, i.e., element or object types that don't exist in regular
>> Org syntax. See `math-block' type in "ox-latex.el", in particular
>> `org-latex-math-block-tree-filter'.
>
> Now that I actually started work on my exporter, I'd like to investigate
> this further. The thing is, I'm not sure where to start. First of all,
> I have a bit old Org-mode (without latex-math-blocks); I guess I'll just
> have to update it (I'll try to do an Elpa update in a minute). But my
> question is:
>
> 1. Is it a good idea to instrument `org-latex--wrap-latex-math-block'
> for Edebug to learn what's happening?
>
> 2. Is there any other (possibly simpler) instance of pseudo-blocks I
> could study? It seems to me (from the docstring) that latex-math-blocks
> are a bit tricky; what I'm interested in is more like creating a new
> element similar to e.g. italics.
>
> (Reagrdless of the answer, I'll try with Edebug, but I'm a bit afraid
> that I won't understand what's going on).
>
> Also, if (when?) I "get it", I'm going to describe the process of adding
> a pseudo-object somewhere (I consider my blog, or maybe I could upload
> it to Worg?), so that other people can learn it easier. But for now, I
> might need help.
>
> 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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-11-26 2:46 ` John Kitchin
@ 2014-11-26 14:23 ` John Kitchin
0 siblings, 0 replies; 19+ messages in thread
From: John Kitchin @ 2014-11-26 14:23 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: emacs-orgmode
I played around with this a little. Here is a minimal kind of example
with a custom exporter that handles quiz blocks separately. The quiz
block can have some attributes defined that get used in rendering the
HTML. Is this along the lines of what you are trying to do?
* A custom type
#+BEGIN_EXAMPLE
Example text in a block to make sure it gets handled
#+END_EXAMPLE
Some instructions for the quiz.
#+ATTR_quiz: :points 5 :correct-answer A
#+BEGIN_quiz
test quiz
- [ ] answer A
- [ ] answer B
#+END_quiz
#+BEGIN_SRC emacs-lisp :exports none
(defun my-org-html-export-block (export-block contents info)
"Transcode a EXPORT-BLOCK element from Org to HTML.
CONTENTS is nil. INFO is a plist used as a communication
channel. QUIZ blocks are handled separately."
(cond
;; handle our special quiz block
((string= (org-element-property :type export-block) "QUIZ")
(format
"<b>got it:</b> %s points, correct answer = %s
<br>
You would have to parse the body to generate your html here.
<br>
<pre>%s</pre>"
(plist-get
(read (format "%s" (org-element-property :attr_quiz export-block)))
:points)
(plist-get
(read (format "%s" (org-element-property :attr_quiz export-block)))
:correct-answer)
(org-element-property :value export-block)
))
;; handle every other kind of block
(t
(org-html-export-block (export-block contents info)))))
(org-export-define-derived-backend 'my-html 'html
:translate-alist '((export-block . my-org-html-export-block))
;; quiz blocks will not be parsed, they are handled directly in org-html-export-block.
:export-block "quiz"
)
(browse-url (org-export-to-file 'my-html "custom-element.html"))
#+END_SRC
#+RESULTS:
: #<process open custom-element.html>
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> Could you remind us of what you are trying to do? It seems like you may
> not necessarily need custom elements (although that could be
> useful). For example, you can put a lot of information in properties of
> a headline.
>
> You might be interested in this:
>
> http://kitchingroup.cheme.cmu.edu/blog/2014/11/23/Machine-gradable-quizzes-in-emacs+org-modex/
>
> I recently used this is in my class of 58 students (who all used emacs
> and org-mode to take a quiz!).
>
>
> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>
>> Hello there,
>>
>> this is close to necromancy, but let me revive this old thread.
>>
>> On 2014-03-16, at 11:16, Nicolas Goaziou wrote:
>>
>>> Another, more advanced option, is to use a parse tree filter to create
>>> pseudo-types, i.e., element or object types that don't exist in regular
>>> Org syntax. See `math-block' type in "ox-latex.el", in particular
>>> `org-latex-math-block-tree-filter'.
>>
>> Now that I actually started work on my exporter, I'd like to investigate
>> this further. The thing is, I'm not sure where to start. First of all,
>> I have a bit old Org-mode (without latex-math-blocks); I guess I'll just
>> have to update it (I'll try to do an Elpa update in a minute). But my
>> question is:
>>
>> 1. Is it a good idea to instrument `org-latex--wrap-latex-math-block'
>> for Edebug to learn what's happening?
>>
>> 2. Is there any other (possibly simpler) instance of pseudo-blocks I
>> could study? It seems to me (from the docstring) that latex-math-blocks
>> are a bit tricky; what I'm interested in is more like creating a new
>> element similar to e.g. italics.
>>
>> (Reagrdless of the answer, I'll try with Edebug, but I'm a bit afraid
>> that I won't understand what's going on).
>>
>> Also, if (when?) I "get it", I'm going to describe the process of adding
>> a pseudo-object somewhere (I consider my blog, or maybe I could upload
>> it to Worg?), so that other people can learn it easier. But for now, I
>> might need help.
>>
>> 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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Extending the Org syntax by a custom exporter - how to do it?
2014-11-25 21:25 ` Marcin Borkowski
2014-11-25 21:46 ` Marcin Borkowski
2014-11-26 2:46 ` John Kitchin
@ 2014-11-26 11:59 ` Nicolas Goaziou
2 siblings, 0 replies; 19+ messages in thread
From: Nicolas Goaziou @ 2014-11-26 11:59 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: emacs-orgmode
Hello,
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> Now that I actually started work on my exporter, I'd like to investigate
> this further. The thing is, I'm not sure where to start. First of all,
> I have a bit old Org-mode (without latex-math-blocks); I guess I'll just
> have to update it (I'll try to do an Elpa update in a minute). But my
> question is:
>
> 1. Is it a good idea to instrument `org-latex--wrap-latex-math-block'
> for Edebug to learn what's happening?
Possibly, but you need to start out with a tiny document and have
`print-level' and `print-length' set to nil.
Anyway, it is a straightforward function: it looks for a math-related
object in the parse tree. When it finds one (which needs to be checked
first as type is an insufficient information), it inserts an empty
pseudo object before it. Then, it moves the math-related object, and
every contiguous math-related objects, within that pseudo object.
> 2. Is there any other (possibly simpler) instance of pseudo-blocks I
> could study? It seems to me (from the docstring) that latex-math-blocks
> are a bit tricky; what I'm interested in is more like creating a new
> element similar to e.g. italics.
A slightly simpler example can be found in
`org-latex--wrap-latex-matrices' (I think you'll need to study
development version). There is also
`org-export--remove-uninterpreted-data-1' in "ox.el".
Anyway, an example of what you're trying to achieve would help.
> Also, if (when?) I "get it", I'm going to describe the process of adding
> a pseudo-object somewhere (I consider my blog, or maybe I could upload
> it to Worg?), so that other people can learn it easier.
I have a TODO to document it at
http://orgmode.org/worg/dev/org-element-api.html
and add a short note on how to use them at
http://orgmode.org/worg/dev/org-export-reference.html
However, I have the feeling that the UI is not complete yet. For
example, at the moment, pseudo-objects are mostly wrapped around
existing objects, so a function `org-element-wrap' (with DATUM START END
as arguments, assuming that START and END are siblings) may be
implemented.
Anyway, feel free to document it in the "official" references. We can
always update it later.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 19+ messages in thread