-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
environments in ConTeXt? #2
Comments
Hi @ousia, sorry for the delay. Real Life got a bit hectic the last two days. My issue is not with translating LaTeX to ConTeXt per se, but with how I can modify I knew that ConTeXT uses However I also got confirmed what I seemed to remember that ConTeXT mostly uses square brackets for the arguments to I have been thinking of extracting all arguments as classes or class fragments whose contents match the regular expression no warnings 'uninitialized';
my($name, $args) = grep {length} split /\#/, $env_attr;
my $classes = $env_obj->attr->{class};
unless ( @$classes ) { # if no classes were already defined
my @classy_args = $args =~ /[\{\[]([-_a-zA-Z0-9]+)[\]\}]/g;
push @$classes, join '_', $name, @classy_args;
} Then the only difference between filtering for LaTeX or ConTeXT output would be the sprintf formats used to produce the raw markup for the start/end of environments: +{
latex => {
begin => '\\begin{%s}%s%s',
end => '\\end{%s}',
}
context => {
begin => '\\start%s%s%s',
end => '\\stop%s',,
}
} so that you could write something like <div env="foo#[bar-baz]{quux}"> and get, depending on output format:
Naturally this is not meant to produce LaTeX and ConTeXT from the same source, but the filter could use the same routine for LaTeX and ConTeXT, apart from the sprintf formats. Do you think that would work? Also: is it safe to assume that the span body, as an argument to an ordinary ConTeXT command, ends up inside curly brackets? |
@BjP, sorry for the delay. I forgot to mention that I cannot code. Sorry, but your regular expression and the perl snippet are almost all Greek to me. From your sample, I wonder whether this filtering makes sense with ConTeXt. I mean, ConTeXt can typeset from XML sources natively. As long as you have valid XHTML from pandoc, you don’t need to add an extra layer. I guess this is a much better method. But as promised, I try to reply to your questions:
I wonder whether the former is valid LaTeX.
I would say this is not valid ConTeXt. At least Depending on the element, environments in ConTeXt use pairs of brackets. Most of them only one, but there are some environments with two, such as in:
Braces in ConTeXt are used to group text modified by switches: mainly language and font switches. A sample that shows both:
This is different from LaTeX:
Again, I wonder whether it is simply better to handle XHTML with ConTeXt natively. I have a question about your sample. One of the main benefits of markup languages (either XML-based, lightweight or even TeX-based) is the separation of layout from content. With the logical approach, text markup only needs classes (and identifiers, in some cases). Formatting itself is done later with CSS, or in the preamble of the document (in TeX). I must be missing something, but when one has to define so complex attributes in the markdown source, I think (s)he is also making the task much harder than it should be. Mainly because it is mixing layout and content the bad way. There are probably more than a couple of misunderstandings (if not plain mistakes) in my explanation. I don’t doubt that your filters serve important goals. Probably the LaTeX writer should be improved not to need those filters for basic features. Language switching is a basic feature when you write documents in other language than US English, because this is the default language in TeX. And also when you have multilingual documents, because in TeX hyphenation is enabled by default (svenska seems to be hyphenated svens-ka in Swedish [and in US English wrongly as sven-ska]). And in my (mis?)understanding, it is really hard to handle a LaTeX document when the user cannot modify layout. I wonder whether it even makes sense. Because documents will always have the default layout. But again, I must be missing a lot of things. Of course, don’t hesitate to ask whatever you need about ConTeXt. It might help that you include the most complex example you can think in both markdown and LaTeX. BTW, for language tagging in markdown, there is an specific issue (jgm/pandoc/issues/895), but the people that need this feature don’t comment there. It is just to show the real demand that language tagging has in pandoc. |
Hi @bpj,
the simplest environment in ConTeXt is:
But I guess you need something more complex.
Could you elaborate what you need from environments in ConTeXt? Please, include samples of those environments in LaTeX.
The text was updated successfully, but these errors were encountered: