Re: Putting LaTeX inside a figure environment on export

2022-04-09 Thread Jason Ross




On 4/9/22 12:36, William Denton wrote:
Is there a way to get a line of LaTeX inside a figure environment when 
exporting from Org? 



For example, let's say I have:

     #+caption: This is a large tree
     [[file:large_tree.jpg]]




I want to use this to generate an entry in an index:

    \index[photos]{Tree}

Is there a way to get that *inside* the figure environment?  If it is, 
then the page number is correct.




Does the following work?

#+caption: This is a large tree @@latex:\index[photos]{Tree}@@
[[file:large_tree.jpg]]

Resulting LaTeX:

\begin{figure}[htbp]
\centering
\includegraphics[width=.9\linewidth]{large_tree.jpg}
\caption{This is a large tree \index[photos]{Tree}}
\end{figure}
\end{document}



Re: Configuring ox-context

2021-12-24 Thread Jason Ross




On 12/23/21 12:16 PM, Denis Maier wrote:
What do you think about using context's structurelevels instead? That 
would allow users to define their own mappings.


Denis


That looks like a brilliant solution. I'll have to give it a deeper look 
to know for sure though - table of contents commands need the headline 
names in order to set up the depth properly. I don't know if there is a 
workaround for this in ConTeXt. But, I think this would satisfy Juh's 
needs as well. Adding \definesectionlevels to the preamble would allow 
them to have whatever sectioning scheme they want.


Jason



Re: Configuring ox-context

2021-12-22 Thread Jason Ross

On 12/22/21 3:24 AM, juh wrote:

In the meantime I debugged my context styles and discovered that ox-
context starts with section not with chapters. My styles are always
book styles starting at chapter level. *feeling a little dumb*

I browsed through the code and found no hint for a book-like preset or
a switch to start at chapter level. I made a feature request about
this.



Thank you for bringing this up. I'd like to discuss this a bit with you
before implementing such a feature.

I'm not sure how an implementation of this would look to the end user.
ConTeXt has the following system:
https://wiki.contextgarden.net/Command/_section

\part   highest level of sectioning
\chapterlevel 2
\sectionlevel 3
\subsection level 4
\subsubsection  level 5
\subsubsubsection   level 6
\subsubsubsubsectionlevel 7
\title  level 2, unnumbered
\subjectlevel 3, unnumbered
\subsubject level 4, unnumbered
\subsubsubject  level 5, unnumbered
\subsubsubsubject   level 6, unnumbered
\subsubsubsubsubjectlevel 7, unnumbered


So there are a couple of questions that need to be answered:

1. There's no "level 1, unnumbered" sectioning command in ConTeXt.
   How should this be handled?
2. How does the user specify which sectioning scheme to use?

Question (1) implies that the user may need to choose their highest
level to be either a part or a chapter in order to have unnumbered
level 1 sections. Things start to get complicated if we do that.

To avoid these questions, I went with the simplest implementation
possible and just concatenated "sub"*n with either "section" or
"subject" to create a sectioning command of depth n.

My understanding is that the sectioning commands are flexible enough
that any desired result in the output pdf can be produced by modifying
the sectioning commands in the preamble. However, if you are using
existing environments that rely on those specific names you are out of
luck.


For your purposes, if you need a fix _right now_, consider overriding
the definition of `org-context--get-headline-command` to something
like this:

#+begin_src elisp
(defun org-context--get-headline-command (headline info)
  "Create a headline name with the correct depth.
HEADLINE is the headline object. INFO is a plist containing
contextual information."
  (let* ((level (org-export-get-relative-level headline info))
 (numberedp (org-export-numbered-headline-p headline info))
 (hname
  (cond
   ((and (= 1 level) numberedp) "chapter")
   ((= 1 level) "title")
   (t (let ((prefix (apply 'concat (make-list (+ level (- 2)) 
"sub")))

(suffix (if numberedp "section" "subject")))
(concat prefix suffix)
 (notoc (org-export-excluded-from-toc-p headline info)))
(if notoc
(format "%sNoToc" hname)
  hname)))
#+end_src




One more thing.

#+begin_quote

results in the verbatim line

OrgBlockQuoteEnu­mEmpty 1

in the pdf and a very indented quote block.

In html export I get an normal indented blockquote.



This is fixed on the "develop" branch as of today. I missed a comma...


Thanks,

Jason



Re: Configuring ox-context

2021-12-21 Thread Jason Ross




On 12/21/21 10:56 AM, juh wrote:

Am Dienstag, dem 21.12.2021 um 19:36 +0100 schrieb juh

Ok, one thing solved.

I normally call context with --mode=trimsize to activate the given
trimsize. Can I set this in org-mode?

When I manually compile test.mkiv I get the right page dimensions but
the layout  is scrambled. Maybe interferences with the default
settings?

Sorry, but I am still trying to understand what is going on in the
background of emacs export.


juh


Try `(setq org-context-pdf-process '("context --mode=trimsize %f"))`
to set this as the default.

Jason



Re: Configuring ox-context

2021-12-21 Thread Jason Ross




On 12/21/21 9:55 AM, juh wrote:


Yes:

%=== 


% Preset Commands
%=== 


\environment juh.env-garamond

\environment juh.env-garamond-trimsize5-8

\environment juh.env-makeups

\environment juh.env-umbruch

\environment juh.env-heading

\environment juh.env-layout

\environment juh.env-header-footer

\environment juh.env-ligaturen

When I manually run the mkiv file I get this.

There is an error with juh.env-makeups.tex which does not show up, when 
I use the environment in an other context. I removed it and got no 
change in layout.


I attached the intermediate mkiv-file and the log.


There is a problem on the ConTeXt side of things. ox-context just calls 
the ConTeXt process on the output file (it's exactly equivalent to 
calling `context test.mkiv` from the terminal).


Jason



Re: Configuring ox-context

2021-12-21 Thread Jason Ross




On 12/21/21 7:50 AM, juh wrote:

Dear all,

this configuration does not work.

#+begin_src emacs-lisp
     (use-package ox-context
   :straight (ox-context :type git :host github :repo 
"Jason-S-Ross/ox-context")

     :config
     (add-to-list 'org-context-presets-alist
  '("book" .
    (:literal "\n\\environment juh.env-garamond
   \n\\environment juh.env-garamond-trimsize5-8
   \n\\environment juh.env-makeups
   \n\\environment juh.env-umbruch
   \n\\environment juh.env-heading
   \n\\environment juh.env-layout
   \n\\environment juh.env-header-footer
   \n\\environment juh.env-ligaturen"
     :template "report"
     :snippets ("title-article")
#+end_src

test.org:

#+title: Test
#+context_preset: book
#+context_snippet: title-snippet

I get an export but the styles are not applied.

Any hints?
juh


Your configuration looks correct to me.

Can you verify that the lines

\environment juh.env-garamond
\environment juh.env-garamond-trimsize5-8
\environment juh.env-makeups
\environment juh.env-umbruch
\environment juh.env-heading
\environment juh.env-layout
\environment juh.env-header-footer
\environment juh.env-ligaturen

appear in the file "test.mkiv" that gets generated?

Thanks,

Jason



Re: Bibliographies on export with ox-context and ox-epub

2021-12-02 Thread Jason Ross

There is a ConTeXt-specific citation exporter that's in development:

https://github.com/Jason-S-Ross/oc-context

On 12/2/21 12:11 AM, juh wrote:

Am 01.12.21 um 16:01 schrieb Eric S Fraga:

What completion engine are you using?  In selectrum, typing C-j at that
point finishes the completion.  Other engines will differ.  You might
also try up-arrow and RET.

Thanks a lot. I use selectrum and would've never found this door out.

juh





Re: Sub-figures in Org Mode

2021-10-26 Thread Jason Ross

Hi Juan,

On 10/22/21 5:00 PM, Juan Manuel Macías wrote:

Hi Jason,

Jason Ross  writes:


Are there any workarounds people use to create subfigures in Org Mode
when exporting to LaTeX? Example output:


In this thread I explain a procedure to export images as subfigures
using org links: https://list.orgmode.org/87mty1an66@posteo.net/

Best regards,

Juan Manuel



Those are some really clever solutions. I hadn't considered using a
dsl for figure options.

I'm looking at declaring a "figure" block the way you are, but
`org-element-map'ing over the links inside the block and processing them
with the "normal" link-handling machinery. That way, image options work
the same way in a subfigure as they do normally.

Here's what I'm messing with for the ConTeXt backend (this relies
on some changes to figure handling I haven't pushed yet):

#+begin_src elisp
(defun org-context--special-block-figure (orig-fun special-block 
contents info)

  (let ((type (org-element-property :type special-block)))
(if (string= "figure" (downcase type))
(let* ((attr (org-export-read-attribute :attr_context 
special-block))

   (links (org-element-map special-block 'link #'identity))
   (placefigure-options
(org-context--format-arguments
 (org-context--get-placefigure-options special-block 
info)))

   (captionp
(mapcan
 (lambda (link)
   (let* ((parent (org-export-get-parent-element link))
  (caption (org-string-nw-p 
(org-context--caption/label-string parent info

 (and caption (list caption
 links))
   (image-codes
(mapconcat
 (lambda (link)
   (let ((figure-string 
(org-context--get-link-figure-string link info)))

 (if captionp
   (let ((caption
  (org-string-nw-p
   (org-context--caption/label-string
(org-export-get-parent-element link) 
info

 (format "{%s}\n{%s}"
 figure-string (or caption "")))
 (format "{%s}" figure-string)))

   )
 links
 "\n"))
   (dimensions
(let* ((rows (plist-get attr :rows))
   (cols (plist-get attr :cols))
   (nlinks (length links)))
  (if
  (and rows cols)
  (cons (string-to-number rows) (string-to-number 
cols))

(cons 1 nlinks
   combination-options)
  (if captionp
   (push (cons "alternative" "text") combination-options)
(push (cons "alternative" "label") combination-options))
  (push (cons "nx" (format "%s" (cdr dimensions))) 
combination-options)
  (push (cons "ny" (format "%s" (car dimensions))) 
combination-options)

  (message (format "%S" combination-options))
  (format "\\startplacefigure[%s]
\\startcombination[%s]
%s
\\stopcombination
\\stopplacefigure"
  placefigure-options
  (org-context--format-arguments combination-options)
  image-codes))
  (funcall orig-fun special-block contents info

(advice-add 'org-context-special-block :around 
#'org-context--special-block-figure)


#+end_src




Sub-figures in Org Mode

2021-10-22 Thread Jason Ross

Are there any workarounds people use to create subfigures in Org Mode
when exporting to LaTeX? Example output:

#+begin_example latex
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[width=.8\linewidth]{image1}
  \caption{1a}
  \label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[width=.8\linewidth]{image2}
  \caption{1b}
  \label{fig:sfig2}
\end{subfigure}
\caption{plots of}
\label{fig:fig}
\end{figure}
\end{document}
#+end_example

Based on how ox-latex.el handles images I don't see how this would be
possible but the people on this list are a lot smarter than I am so
maybe one of you has found a way.



Re: Best way to include METAPOST in ConTeXt exporter

2021-10-05 Thread Jason Ross

Here's a hook that modifies the source blocks to wrap their
output in #+BEGIN/END_METAPOST tags if the ConTeXt backend is used,
before Org Babel gets to them, but otherwise leaves them alone.

I wonder if anyone has any better ideas of how to do this. I'm
modifying the Org source with the hook before the document gets parsed
so that it can be more backend-agnostic but it seems like it would
be better if there was a way to modify the document parse tree
directly instead. I don't like that I'm effectively parsing and
rebuilding (hopefully) the same string in order to change the :result
type.

I also don't like that I don't really have a clean way of turning
the hook on and off with document keywords. This is kind of a nasty
thing to do to a document and users should probably have to explicitly
opt in.

I also found an old answer that describes how to add captions
to figures generated by source blocks:
https://www.mail-archive.com/emacs-orgmode@gnu.org/msg68100.html
Probably not news to many other people on this list but myself :)
#+TITLE: Metapost Handler

This is a basic handler for METAPOST that exports as raw code
when the ConTeXt exporter is used but otherwise does whatever you
tell it to.

#+NAME: hooks
#+BEGIN_SRC emacs-lisp :exports none :results none
(defun format-src-block-arguments (arguments)
  "Returns a formatted plist of header arguments"
  (mapconcat
   (lambda (argument)
 (let ((kw (car argument))
   (vals (cdr argument)))
   (concat (format "%s" kw)
   " "
   (format "%s" vals
   arguments
   " "))
(defun metapost-process-hook (backend)
  "If BACKEND is `context', change metapost code blocks to output
raw code wrapped in #+BEGIN_METAPOST/#+END_METAPOST tags."
  ;; TODO This should be controlled by a flag.
  ;; TODO Check buffer info to see if we are allowed to do this.
  (when (string= backend "context")
(goto-char (point-min))
(let ((case-fold-search t)
  ;; Search for source code with a regex
  (regexp "^[ \t]*#\\+BEGIN_SRC"))
  (while (re-search-forward regexp nil t)
(let* ((objectp (match-end 1))
   (tree (org-element-parse-buffer))
   ;; Get the buffer info plist (need this to export a caption)
   (info (org-combine-plists
 (org-export--get-export-attributes)
 (org-export-get-environment)))
   (info (progn
  (org-export--prune-tree tree info)
  (org-export--remove-uninterpreted-data tree info)
  (org-combine-plists info
  (org-export--collect-tree-properties
   tree info
   ;; Get a code element
   (element
(save-match-data
  (if objectp (org-element-context) (org-element-at-point
   (caption (org-element-property :caption element))
   (type (org-element-type element))
   (begin (copy-marker (org-element-property :begin element)))
   (end (copy-marker
 (save-excursion
   (goto-char (org-element-property :end element))
   (skip-chars-backward " \r\t\n")
   (point
   (block-info (org-babel-get-src-block-info t))
   (language (nth 0 block-info))
   (body (nth 1 block-info))
   (arguments (nth 2 block-info))
   (arguments (delq (assoc :file arguments) arguments))
   (switches (nth 3 block-info))
   (name (nth 4 block-info))
   (start (nth 5 block-info))
   (coderef (nth 6 block-info)))

  (when (or t (string= (downcase language) "metapost"))
;; Remove "file" from `results' setting
(setf (alist-get :results arguments)
  (mapconcat
   #'identity
   (seq-filter
(lambda (a) (not (string= a "file")) )
(split-string (alist-get :results arguments)))
   " "))
;; Add a wrap argument to wrap in a METAPOST special block
(setf (alist-get :wrap arguments) "METAPOST")
(pcase type
  (`src-block
   (progn
 (delete-region begin end)
 (goto-char begin)
 (insert
  (concat
   ;; Captions and names got deleted; add them back
   (when (org-string-nw-p name)
 (format "#+NAME: %s \n" name))
   (when caption
 (format "#+CAPTION: %s\n"
 (org-string-nw-p
  (org-trim
   (org-export-data
(or
 (org-export-get-caption element t)

Re: Best way to include METAPOST in ConTeXt exporter

2021-10-05 Thread Jason Ross
(Apologies to Ihor who I already replied to without cc'ing the list)
===
> If you are in control of the export backend, you can directly process
> the metapost source blocks during export and ignore/filter their output
> as needed.

This is definitely possible, but I don't want to commit to bypassing the
entire Org Babel system right now. I will explore this a bit.

> Or you can use "raw" results by default and format everything as you
> wish in your Org Babel module programatically.

I'm not sure I understand this yet. Would this emit METAPOST code to the
Org buffer? Ideally, I'd like to emit METAPOST code if the backend is
`context`, otherwise, emit a file.

> If above is not sufficient, you can install global export filters that
> can transform the metapost blocks/source blocks/their results as you
> need in other export backends.

This sounds like it might be a good solution. Is it possible to have an
export filter that changes the header arguments of a source block before
Org Babel sees them? If so, ox-context could change all METAPOST source
block header arguments to give raw results wrapped in appropriate tags.

Also, I'm still curious if there's a better way to add #+CAPTION and
#+NAME tags to images generated by source blocks (in any context). It
would be extremely handy to reference figures generated with
matplotlib throughout the document, not just METAPOST drawings.

Thanks,
Jason

On Mon, Oct 4, 2021 at 9:44 AM Ihor Radchenko  wrote:
>
> Jason Ross  writes:
>
> > I had considered using special blocks; they match my mental model the best.
> > However, they don't provide any support for syntax highlighting or opening
> > the block in a new major mode buffer. I'm not sure if it's worth giving up
> > language features in order to use the block that's most intuitive to users.
> >
> > I'm also considering writing an Org Babel module for METAPOST. This could
> > allow METAPOST figures to be included with any export backend. However,
> > if I go this route, there are still some challenges:
>
> If you are in control of the export backend, you can directly process
> the metapost source blocks during export and ignore/filter their output
> as needed.
>
> >#+MACRO: conditional-header (eval (when (not (eq
> > org-export-current-backend 'context)) (concat  "#+HEADER: :results
> > file :file " $1)))
>
> >#+BEGIN_SRC metapost :results drawer :post
> > wrap_metapost(name="my-name", caption="my-caption", data=*this*)
>
> Or you can use "raw" results by default and format everything as you
> wish in your Org Babel module programatically.
>
> If above is not sufficient, you can install global export filters that
> can transform the metapost blocks/source blocks/their results as you
> need in other export backends.
>
> Best,
> Ihor



Re: Best way to include METAPOST in ConTeXt exporter

2021-10-04 Thread Jason Ross
I had considered using special blocks; they match my mental model the best.
However, they don't provide any support for syntax highlighting or opening
the block in a new major mode buffer. I'm not sure if it's worth giving up
language features in order to use the block that's most intuitive to users.

I'm also considering writing an Org Babel module for METAPOST. This could
allow METAPOST figures to be included with any export backend. However,
if I go this route, there are still some challenges:
1. Getting captions and tags attached to the resulting figures is clumsy.
   As far as I know,  this could be done with the :post header argument
   and a wrapper source block, but this would require boilerplate code
   in documents that use this feature
2. I don't know if there's a reasonable way to leverage ConTeXt's native support
   for METAPOST this way; if I ask Org Babel to generate an SVG, ConTeXt then
   has to parse the SVG and (internally) convert it back into METAPOST to
   render in the document. ConTeXt's SVG support (particularly with mathematical
   symbols) is missing some features, so this will be a lossy process.
   Essentially I'd want the module to return a file most of the time, but
   return raw METAPOST (wrapped in some tags) if the ConTeXt backend is used.

Here's a minimal implementation of the source block concept:

# Define a macro to add header arguments UNLESS ConTeXt backend is used
#+MACRO: conditional-header (eval (when (not (eq
org-export-current-backend 'context)) (concat  "#+HEADER: :results
file :file " $1)))

# Define a wrapper block to annotate source block outputs with
# caption and name
#+NAME: wrap_metapost
#+BEGIN_SRC emacs-lisp :var data="" :var caption="" :var name=""
(concat
 (when (org-string-nw-p name) (format "#+NAME: %s\n" name))
 (when (org-string-nw-p caption) (format "#+CAPTION: %s\n" caption))
 (if (eq org-export-current-backend 'context)
 (format "#+BEGIN_METAPOST \n%s\n#+END_METAPOST" data)
   data))
#+END_SRC

# Minimal Org Babel implementation for METAPOST
#+BEGIN_SRC emacs-lisp
(defvar org-babel-default-header-args:metapost
  '((:exports . "results"))
  "Default arguments to use when evaluating a dot source block.")
(defun org-babel-execute:metapost (body params)
  "Execute a block of METAPOST code with org-babel.
This function is called by `org-babel-execute-src-block'."
  (if (cdr (assq :file params))
  (let* ((out-file (cdr (assq :file params)))
 (cmdline (or (cdr (assq :cmdline params))
  (format "-T%s" (file-name-extension out-file
 (cmd (or (cdr (assq :cmd params)) "mpost"))
 (coding-system-for-read 'utf-8) ;use utf-8 with sub-processes
 (coding-system-for-write 'utf-8)
 (in-file (org-babel-temp-file "metapost-")))
(with-temp-file in-file
  (insert (org-babel-expand-body:generic body params)))
(org-babel-eval
 (concat cmd
 " -s 'outputformat=\"svg\"'"
 (format " -s 'outputtemplate=\"%s\"'"
(org-babel-process-file-name out-file))
 " " (org-babel-process-file-name in-file)) "")
nil)
body))
#+END_SRC

# Example Usage
{{{conditional-header(foo.svg)}}}
#+BEGIN_SRC metapost :results drawer :post
wrap_metapost(name="my-name", caption="my-caption", data=*this*)
beginfig(1);
draw origin--(100,100)--(200,0)--cycle;
endfig;
end;
#+END_SRC

This kind of works: It exports to HTML with a nice SVG figure and sends raw
METAPOST code to the backend, with #+CAPTION and #+NAME information
attached. Also, links to the figures work in the buffer as well as the pdf.

However, there's a lot I don't like about this.
1. No SVG preview in the buffer since the `conditional-header` macro doesn't
   get expanded until export time
2. Boilerplate; both the `conditional-header` and `wrap_metapost` definitions
   need to be included in the org file
3. Inconvenient to use since I have to add a macro call and a :post argument
   with weird syntax to every METAPOST figure, and the way captions and tags
   are specified is different.



On Mon, Oct 4, 2021 at 1:39 AM Ihor Radchenko  wrote:
>
> Jason Ross  writes:
>
> > Hello,
> >
> > I'd like to include METAPOST figures in the ConTeXt exporter backend I'm
> > developing. However, I don't know of an idiomatic way to add captions and
> > references for the figures.
>
> You can use affiliated keywords:
>
> (defconst org-element-affiliated-keywords
>   '("CAPTION" "DATA" "HEADER"

Best way to include METAPOST in ConTeXt exporter

2021-10-03 Thread Jason Ross
Hello,

I'd like to include METAPOST figures in the ConTeXt exporter backend I'm
developing. However, I don't know of an idiomatic way to add captions and
references for the figures.

Currently, I export METAPOST with `#+BEGIN_EXPORT metapost` / `#+END_EXPORT`
tags. However, this feature seems to be intended for completely "raw"
outputs
with no markup or tagging in the resulting export. I'm interested in
supporting
at least `#+NAME` and `#+CAPTION` keywords for METAPOST figures so that they
can be referred to in the Org file and also in the exported pdf.

What are some better ways of doing something like this? Source blocks? How
would
a user expect to use a feature like this?

Thanks,

Jason


Re: ConTeXt exporter for Org Mode

2021-08-06 Thread Jason Ross



> There are two minor issues:
>
> - ox-context does not honour #+options: toc: nil  or too: 1
>Since it is possible to add chapter TOCs later,
>it might be a good idea to omit the main TOC or limit it to one level.

This is an excellent catch. Not sure how this slipped by over the months
but I will fix this ASAP.


> - I couldn’t find a way to change the paper size.
>There is
>  ;; US letter paper
>  ("paper-letter" . "\\setuppapersize[letter]")
>in the code, but it doesn’t appear in the output, and I prefer the 
a-sizes (especially 2 x a5 on a4)


To set the paper size in a particular document, add the following to the
document header:

#+CONTEXT_HEADER: \setuppapersize[A4]

The following code will create a "Snippet" for a4 paper size:

(add-to-list
 'org-context-snippets-alist
 '("paper-a4" . "\\setuppapersize[A4]")
 t)

You can then add the setup command to a document with the following:

#+CONTEXT_SNIPPETS: paper-a4

The following will change the settings for the article template:

(let ((article-preset
   (cdr (assoc "article" org-context-presets-alist
  (plist-put article-preset :snippets
 (cons "paper-a4" (plist-get article-preset :snippets


Alternatively, the article template can be modified without declaring
a snippet first with the following:

(let ((article-preset
   (cdr (assoc "article" org-context-presets-alist
  (plist-put article-preset :literal
 (concat (plist-get article-preset :literal)
 "\n\\setuppapersize[A4]")))

> Do you prefer to receive comments here or should I use the githup 
tracker in the future?


Specific bugs like the table of contents setting probably belong in the
github tracker. General questions like "how do I change to A4 paper"
could go either way.


Thank you for the feedback!

Jason



ConTeXt exporter for Org Mode

2021-08-04 Thread Jason Ross

Hello,

I have developed a ConTeXt exporter for Org Mode. It is available at
https://github.com/Jason-S-Ross/ox-context

The exporter provides custom environments for each document element
in an effort to make customization easier, in contrast to the Pandoc
exporter which uses built-in environments for document elements.

I welcome any feedback.

Thanks,
Jason



Inconsistent numbering of verse, example, source blocks

2021-01-25 Thread Jason Ross

Hello,

I'm working on an exporter for ConTeXt and I'm trying to handle
references to paragraph elements in a consistent way. However, there
seems to be some inconsistencies in how such elements are numbered in
the existing exporters.

Here's a MWE:

==

#+TITLE: Numbering Collision

#+NAME: NamedVerse1
#+CAPTION: Named Verse 1
#+BEGIN_VERSE
Mauris ac felis vel velit tristique imperdiet.
#+END_VERSE

Here's a link to verse [[NamedVerse1]]

#+NAME: UnnamedVerse1
#+BEGIN_VERSE
Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.
#+END_VERSE

Here's a link to [[UnnamedVerse1]]

#+NAME: NamedVerse2
#+CAPTION: Named Verse 2
#+BEGIN_VERSE
Aliquam posuere.
#+END_VERSE

Here's a link to verse [[NamedVerse2]]

#+NAME: UnnamedVerse2
#+BEGIN_VERSE
Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi.
#+END_VERSE

Here's a link to [[UnnamedVerse2]]


#+NAME: NamedEx1
#+CAPTION: Named Example 1
#+BEGIN_EXAMPLE
Mauris ac felis vel velit tristique imperdiet.
#+END_EXAMPLE

Here's a link to Example [[NamedEx1]]

#+NAME: UnnamedEx1
#+BEGIN_EXAMPLE
Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.
#+END_EXAMPLE

Here's a link to [[UnnamedEx1]]

#+NAME: NamedEx2
#+CAPTION: Named Example 2
#+BEGIN_EXAMPLE
Aliquam posuere.
#+END_EXAMPLE

Here's a link to Example [[NamedEx2]]

#+NAME: UnnamedEx2
#+BEGIN_EXAMPLE
Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi.
#+END_EXAMPLE

Here's a link to [[UnnamedEx2]]

#+NAME: NamedSrc1
#+CAPTION: Named Source 1
#+BEGIN_SRC
Mauris ac felis vel velit tristique imperdiet.
#+END_SRC

Here's a link to Source [[NamedSrc1]]

#+NAME: UnnamedSrc1
#+BEGIN_SRC
Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.
#+END_SRC

Here's a link to [[UnnamedSrc1]]

#+NAME: NamedSrc2
#+CAPTION: Named Source 2
#+BEGIN_SRC
Aliquam posuere.
#+END_SRC

Here's a link to Source [[NamedSrc2]]

#+NAME: UnnamedSrc2
#+BEGIN_SRC
Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi.
#+END_SRC

Here's a link to [[UnnamedSrc2]]

==

I'm not sure what the "Canonical" numbering ought to be but what I see
is as follows:

For the HTML exporter:
 Here’s a link to verse 1
 Here’s a link to 2
 Here’s a link to verse 2
 Here’s a link to 3
 Here’s a link to Example 1
 Here’s a link to 2
 Here’s a link to Example 2
 Here’s a link to 3
 Here’s a link to Source 1
 Here’s a link to 2
 Here’s a link to Source 2
 Here’s a link to 3

For the LaTeX exporter:
 (no links to verses or examples)
 Here's a link to Source 1
 Here's a link to ??
 Here's a link to Source 2
 Here's a link to ??

For the markdown and, plain text exporters:
 Here’s a link to verse 1
 Here’s a link to 2
 Here’s a link to verse 3
 Here’s a link to 4
 Here’s a link to Example 1
 Here’s a link to 2
 Here’s a link to Example 3
 Here’s a link to 4
 Here’s a link to Source 1
 Here’s a link to 2
 Here’s a link to Source 3
 Here’s a link to 4

So, my question is twofold:
1. Is this a bug?
2. What is the most desired numbering for these elements in the future?


Thanks,

Jason



Re: Org to ConTeXt exporter?

2021-01-12 Thread Jason Ross

I'm happy to hear you're able to use it! Any feedback or criticism
is appreciated, and I'd like to know what your output format looks
like if you're able to share.


Thanks,

Jason

On 1/9/21 9:42 AM, Juan Manuel Macías wrote:

Hello, Jason,

Jason Ross  writes:


I recently had the same thought and I've started working on one.
You can see it here:

https://github.com/Jason-S-Ross/ox-context/

It's no substitute for the LaTeX exporter but it implements a lot
of the basics. I'm deriving from the LaTeX exporter but I have
to override most of the transcoders so it may be better to start
from scratch.

Disclaimer: I'm learning elisp as I go, so please excuse the
rough edges.


That's great news! I've been testing it a bit and it works very good. Of
course, I encourage you to keep up this excellent work.

Regards,

Juan Manuel



Jason Ross








Re: Org to ConTeXt exporter?

2021-01-07 Thread Jason Ross

On 12/28/20 5:38 AM, Juan Manuel Macías wrote:

Hi,

Just out of curiosity, I am wondering if there are plans to create an
Org to ConTeXt exporter in the future, or if there is already some work
in progress on this front.

I have to say that among TeX formats I tend to prefer LaTeX to ConTeXt;
but ConTeXt has very interesting features (grid typesetting, for
example) that LaTeX lacks (for now) and has a more monolithic structure,
that is, it does not need to be extended through packages as in LaTeX.

Regards,

Juan Manuel



I recently had the same thought and I've started working on one.
You can see it here:

https://github.com/Jason-S-Ross/ox-context/

It's no substitute for the LaTeX exporter but it implements a lot
of the basics. I'm deriving from the LaTeX exporter but I have
to override most of the transcoders so it may be better to start
from scratch.

Disclaimer: I'm learning elisp as I go, so please excuse the
rough edges.


Jason Ross



Re: Org to ConTeXt exporter?

2021-01-07 Thread Jason Ross

On 2020-12-28, at 14:38, Juan Manuel Macías  wrote:

> Hi,
>
> Just out of curiosity, I am wondering if there are plans to create an
> Org to ConTeXt exporter in the future, or if there is already some work
> in progress on this front.
>
> I have to say that among TeX formats I tend to prefer LaTeX to ConTeXt;
> but ConTeXt has very interesting features (grid typesetting, for
> example) that LaTeX lacks (for now) and has a more monolithic structure,
> that is, it does not need to be extended through packages as in LaTeX.

I recently had the same thought and I've started working on one.
You can see it here:

https://github.com/Jason-S-Ross/ox-context/

It's no substitute for the LaTeX exporter but it implements a lot
of the basics. I'm deriving from the LaTeX exporter but I have
to override most of the transcoders so it may be better to start
from scratch.

Disclaimer: I'm learning elisp as I go, so please excuse the
rough edges.


Jason Ross