emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Extending the Org syntax by a custom exporter - how to do it?
@ 2014-03-15 10:10 Marcin Borkowski
  2014-03-15 11:10 ` John Kitchin
  2014-03-15 21:22 ` Marcin Borkowski
  0 siblings, 2 replies; 19+ messages in thread
From: Marcin Borkowski @ 2014-03-15 10:10 UTC (permalink / raw)
  To: Org-mode mailing list

Hi list,

I'd like to extend the LaTeX exporter to be able to prepare tests with
Org-mode.  Four basic kinds of tests I'm thinking about are: single
choice test, multiple choice test, cloze test and an "open" question
(where the expected answer is, say, at most 5 lines of text).  It
would enable the user to typeset both the test for students and an
answer sheet for the teacher to facilitate grading. (If - and when - I
succeed in doing this, next logical step is preparing HTML/Javascript
tests from the same Org-mode source.)  I have a few questions, though.

1. Is it possible to employ syntax like ____{noon|midday} to denote a
cloze with two possible answers?  It might get translated to LaTeX as
e.g. \cloze{{noon},{midday}} or similar, and a LaTeX package would
take care to typeset this correctly.  Is there any similar thing (i.e.,
an exporter built on some existing one) so that I can look at an
example of code doing such thing?

2. What would you suggest as the input format on the Org side of
things?  My suggestion for the cloze syntax is shown above (let us
assume that at least two or three underscores are needed to
distinguish this from subscript, and some form of escaping the pipe
symbol and braces might be necessary.  Alternatively, it might be
configurable to use e.g. ____[noon/midday] (or other characters).

What about SCTs/MCTs?  My idea would be to employ plain lists with
checkboxes - they seem to be pretty useless outside Org-mode anyway,
and I imagine that it could be something like this:

#+<SOME MAGICAL LINE MEANING: THIS IS A MULTIPLE CHOICE TEST>
- [ ] wrong answer
- [X] good answer
- [X] another good answer
- [ ] a completely stupid answer

As for "open" questions, I have no good idea.  Maybe something like

#+LINES: 5

but what about example answers (for the teacher grading the test)?
Maybe it would be better to say:
#+BEGIN_ANSWER
(Here goes the right answer.)
#+END_ANSWER,

but is it possible to pass a parameter (number of lines) to
#+BEGIN_ANSWER?

3. Bonus question: would there be any demand (apart from myself) for
such an exporter?

What do you think?

-- 
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-15 10:10 Extending the Org syntax by a custom exporter - how to do it? Marcin Borkowski
@ 2014-03-15 11:10 ` John Kitchin
  2014-03-15 11:25   ` Marcin Borkowski
  2014-03-15 21:22 ` Marcin Borkowski
  1 sibling, 1 reply; 19+ messages in thread
From: John Kitchin @ 2014-03-15 11:10 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 2772 bytes --]

I suggest you look into the acrotex package (http://www.acrotex.net/) which
has good support for tests. You can use the regular latex exporter with
that.

John

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



On Sat, Mar 15, 2014 at 6:10 AM, Marcin Borkowski <mbork@wmi.amu.edu.pl>wrote:

> Hi list,
>
> I'd like to extend the LaTeX exporter to be able to prepare tests with
> Org-mode.  Four basic kinds of tests I'm thinking about are: single
> choice test, multiple choice test, cloze test and an "open" question
> (where the expected answer is, say, at most 5 lines of text).  It
> would enable the user to typeset both the test for students and an
> answer sheet for the teacher to facilitate grading. (If - and when - I
> succeed in doing this, next logical step is preparing HTML/Javascript
> tests from the same Org-mode source.)  I have a few questions, though.
>
> 1. Is it possible to employ syntax like ____{noon|midday} to denote a
> cloze with two possible answers?  It might get translated to LaTeX as
> e.g. \cloze{{noon},{midday}} or similar, and a LaTeX package would
> take care to typeset this correctly.  Is there any similar thing (i.e.,
> an exporter built on some existing one) so that I can look at an
> example of code doing such thing?
>
> 2. What would you suggest as the input format on the Org side of
> things?  My suggestion for the cloze syntax is shown above (let us
> assume that at least two or three underscores are needed to
> distinguish this from subscript, and some form of escaping the pipe
> symbol and braces might be necessary.  Alternatively, it might be
> configurable to use e.g. ____[noon/midday] (or other characters).
>
> What about SCTs/MCTs?  My idea would be to employ plain lists with
> checkboxes - they seem to be pretty useless outside Org-mode anyway,
> and I imagine that it could be something like this:
>
> #+<SOME MAGICAL LINE MEANING: THIS IS A MULTIPLE CHOICE TEST>
> - [ ] wrong answer
> - [X] good answer
> - [X] another good answer
> - [ ] a completely stupid answer
>
> As for "open" questions, I have no good idea.  Maybe something like
>
> #+LINES: 5
>
> but what about example answers (for the teacher grading the test)?
> Maybe it would be better to say:
> #+BEGIN_ANSWER
> (Here goes the right answer.)
> #+END_ANSWER,
>
> but is it possible to pass a parameter (number of lines) to
> #+BEGIN_ANSWER?
>
> 3. Bonus question: would there be any demand (apart from myself) for
> such an exporter?
>
> What do you think?
>
> --
> Marcin Borkowski
> http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
> Adam Mickiewicz University
>
>

[-- Attachment #2: Type: text/html, Size: 3596 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Extending the Org syntax by a custom exporter - how to do it?
  2014-03-15 11:10 ` John Kitchin
@ 2014-03-15 11:25   ` Marcin Borkowski
  2014-03-15 11:29     ` Marcin Borkowski
  0 siblings, 1 reply; 19+ messages in thread
From: Marcin Borkowski @ 2014-03-15 11:25 UTC (permalink / raw)
  To: John Kitchin

Dnia 2014-03-15, o godz. 07:10:31
John Kitchin <jkitchin@andrew.cmu.edu> napisał(a):

> I suggest you look into the acrotex package (http://www.acrotex.net/)
> which has good support for tests. You can use the regular latex
> exporter with that.

Thanks!

However, what I'm really after is the HTML/JS export.  Since I feel
comfortably in LaTeX (also low-level), LaTeX export would be kind of a
warm-up for me, where the LaTeX part would be mostly easy and
"recreational", and Elisp/Org-mode part would be more difficult and
something relatively new for me (I did some simple-to-medium Elisp
hacking before, but not with the Org exporter, which intimidates me a
lot...).  Going for HTML, where both sides of the equation (Org-mode
and Javascript) are more or less new to me, seems to be not the best
idea for the first step.

> John

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-15 11:25   ` Marcin Borkowski
@ 2014-03-15 11:29     ` Marcin Borkowski
  0 siblings, 0 replies; 19+ messages in thread
From: Marcin Borkowski @ 2014-03-15 11:29 UTC (permalink / raw)
  To: emacs-orgmode

Dnia 2014-03-15, o godz. 12:25:13
Marcin Borkowski <mbork@wmi.amu.edu.pl> (by way of Marcin Borkowski
<mbork@wmi.amu.edu.pl>) napisał(a):

> Dnia 2014-03-15, o godz. 07:10:31
> John Kitchin <jkitchin@andrew.cmu.edu> napisał(a):
> 
> > I suggest you look into the acrotex package
> > (http://www.acrotex.net/) which has good support for tests. You can
> > use the regular latex exporter with that.
> 
> Thanks!
> 
> However, what I'm really after is the HTML/JS export.  Since I feel
> comfortably in LaTeX (also low-level), LaTeX export would be kind of a
> warm-up for me, where the LaTeX part would be mostly easy and
> "recreational", and Elisp/Org-mode part would be more difficult and
> something relatively new for me (I did some simple-to-medium Elisp
> hacking before, but not with the Org exporter, which intimidates me a
> lot...).  Going for HTML, where both sides of the equation (Org-mode
> and Javascript) are more or less new to me, seems to be not the best
> idea for the first step.

Also, as a second thought: the really important part for me here (on
the Org-mode side, again) is the potential Org-ish syntax for
specifying tests, and the question of how to modify the Org exporter
to recognize it.

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-15 10:10 Extending the Org syntax by a custom exporter - how to do it? Marcin Borkowski
  2014-03-15 11:10 ` John Kitchin
@ 2014-03-15 21:22 ` Marcin Borkowski
  2014-03-16 10:16   ` Nicolas Goaziou
  1 sibling, 1 reply; 19+ messages in thread
From: Marcin Borkowski @ 2014-03-15 21:22 UTC (permalink / raw)
  To: emacs-orgmode

Dnia 2014-03-15, o godz. 11:10:59
Marcin Borkowski <mbork@wmi.amu.edu.pl> napisał(a):

> Hi list,
> 
> I'd like to extend the LaTeX exporter to be able to prepare tests with
> Org-mode.  Four basic kinds of tests I'm thinking about are: single
> choice test, multiple choice test, cloze test and an "open" question
> (where the expected answer is, say, at most 5 lines of text).  It
> would enable the user to typeset both the test for students and an
> answer sheet for the teacher to facilitate grading. (If - and when - I
> succeed in doing this, next logical step is preparing HTML/Javascript
> tests from the same Org-mode source.)  I have a few questions, though.
> 
> 1. Is it possible to employ syntax like ____{noon|midday} to denote a
> cloze with two possible answers?  It might get translated to LaTeX as
> e.g. \cloze{{noon},{midday}} or similar, and a LaTeX package would
> take care to typeset this correctly.  Is there any similar thing
> (i.e., an exporter built on some existing one) so that I can look at
> an example of code doing such thing?
> 
> 2. What would you suggest as the input format on the Org side of
> things?  My suggestion for the cloze syntax is shown above (let us
> assume that at least two or three underscores are needed to
> distinguish this from subscript, and some form of escaping the pipe
> symbol and braces might be necessary.  Alternatively, it might be
> configurable to use e.g. ____[noon/midday] (or other characters).
> 
> What about SCTs/MCTs?  My idea would be to employ plain lists with
> checkboxes - they seem to be pretty useless outside Org-mode anyway,
> and I imagine that it could be something like this:
> 
> #+<SOME MAGICAL LINE MEANING: THIS IS A MULTIPLE CHOICE TEST>
> - [ ] wrong answer
> - [X] good answer
> - [X] another good answer
> - [ ] a completely stupid answer
> 
> As for "open" questions, I have no good idea.  Maybe something like
> 
> #+LINES: 5
> 
> but what about example answers (for the teacher grading the test)?
> Maybe it would be better to say:
> #+BEGIN_ANSWER
> (Here goes the right answer.)
> #+END_ANSWER,
> 
> but is it possible to pass a parameter (number of lines) to
> #+BEGIN_ANSWER?
> 
> 3. Bonus question: would there be any demand (apart from myself) for
> such an exporter?
> 
> What do you think?

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.

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-15 21:22 ` Marcin Borkowski
@ 2014-03-16 10:16   ` Nicolas Goaziou
  2014-03-16 11:18     ` Marcin Borkowski
                       ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Nicolas Goaziou @ 2014-03-16 10:16 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: emacs-orgmode

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

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'.


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-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 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 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 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-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

* 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

end of thread, other threads:[~2014-11-26 14:24 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-15 10:10 Extending the Org syntax by a custom exporter - how to do it? Marcin Borkowski
2014-03-15 11:10 ` John Kitchin
2014-03-15 11:25   ` Marcin Borkowski
2014-03-15 11:29     ` Marcin Borkowski
2014-03-15 21:22 ` Marcin Borkowski
2014-03-16 10:16   ` Nicolas Goaziou
2014-03-16 11:18     ` Marcin Borkowski
2014-03-16 11:57       ` Nicolas Goaziou
2014-03-16 13:33         ` Marcin Borkowski
2014-03-16 14:12           ` Nicolas Goaziou
2014-03-17 15:43             ` Marcin Borkowski
2014-03-16 16:05         ` Aaron Ecay
2014-03-17 16:31     ` Marcin Borkowski
2014-03-22 11:23       ` Nicolas Goaziou
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).