Although the end-problem that this would solve is a TeX one (installing a new font for PDF output), this particular solution that I'm looking for is a Sphinx issue.
Sphinx uses standard LaTeX when making PDFs, which is fine so far, but I need to install a new font and have tried and failed.
I understand this is a far easier process using XeLateX, so would like to know if there is an extension or some way to configure Sphinx to make it use the XeLaTeX builder instead.
I think this boils down to getting in some LaTeX instructions before sphinx starts its work.
At the start of your index.rst, you can add a "raw" entry that's passed verbatim to latex:
.. raw:: latex
\setyournicefontorwhatever(beautiful.ttf)
Does that help to get the correct font in? I'm using raw latex entries myself to remove the section numbers from part of my documentation (\setcounter{secnumdepth}{-1} in a similar "raw" entry).
Also, the Sphinx documentation on build options has some things you can try. The most promising looks to be the documentclass item in the latex_documents setting.
It is possible to allow sphinx to use the xelatex builder by modifying the make file to use xelatex, or simply build the doc in two commands....make latex, then xelatex yourdoc.tex. However it is important to disable a number of packages including: fontenc, inputenc, and babel as these eithier dont work at all or may cause issues in future. I think there may be alternative packages in leiu of babel if you wish. Also xelatex already allows for some (but not all) characters that inputenc[utf8] would normally account for.
Disabling these can be done in you conf.py file, this doc shows a good example of how to do this under "Option for Latex":
https://github.com/jterrace/sphinxtr/blob/master/conf.py
I add the following to conf.py when using xelatex:
latex_elements = {
# Additional stuff for the LaTeX preamble.
'preamble': ''' \usepackage{fontspec} \setmainfont{Times New Roman}
''',
'inputenc': '',
'fncychap': '',
'utf8extra': '',
'times': '',
'babel': '\usepackage{polyglossia}',
'cmap': '',
'fontenc': '',
'releasename': '', }
You have to turn off a lot of the default latex packages because xelatex uses other packages or have the functionality built-in.
As of recent Sphinx versions (tested with Sphinx 4.2.0), yes! Simply add this to your conf.py file:
latex_engine = 'xelatex'
Reference: https://www.sphinx-doc.org/en/master/usage/configuration.html?highlight=latex_engine#confval-latex_engine
Related
I use sphinx to generate HTML and PDF documentation, and was using latex until now to generate PDF, but now looking at swapping for rinohtype.
I'm looking at setting up some custom headers and footers, but would like to include variable text into them, for the version number for example, which comes from a sphinx python plugin. I have rst substitutions, for example |version|, that I use in various places in the document, but if I add it to the header via a stylesheet it doesn't get substituted. I also have python variables, for example version, in my conf.py so I also tried to use {version} in my stylesheet, but the builder complains that the variable doesn't exists.
FYI, here is how I tried to define my header :
[contents_page]
header_text = '|document_id| |version| |shortdate|' (header)
[contents_page]
header_text = '{document_id} {version} {shortdate}' (header)
Any idea how to get around that issue ?
Thanks
rinohtype does support including reStructuredText substitutions (|subst|) in document templates, but this is one of the features that isn't documented yet.
To use substitutions in a page header or footer, you need to include them as follows:
[contents_page]
header_text = '{UserStrings.document_id} {UserStrings.version} {UserStrings.shortdate}' (header)
(Actually, I don't remember why I require the UserStrings. prefix. Perhaps there is a good reason for that. If not, that prefix might not be needed in the future.)
Description:
I am trying to integrate a workflow and tools which incorporates vimwiki and Gollum. I want to merely add vimwiki as an extention type for the editor while being processed by Gollum's internal Markdown processor (see "Things I've tried" #1).
Eventually I'd also like to have Gollum default to 'vimwiki' when creating new documents as well.
The project I'm working on can be found at Vimwiki-Gollum-Integration
Testing Specifics:
Gollum version: 4.1.1
The file being tested is valid github markdown
The same content is being tested with different filenames and extensions:
testx.thing
blah.vimwiki
The test files do work fine when they are named with .md extensions
relevant rendering gems installed:
github-markdown
github-markup
kramdown
redcarpet
All code is being tested in a gollum --config file
I'm not well versed in ruby
Things I've tried
Creating a new extension and custom renderer
This works except there is no reason to implement a custom processor (pandoc)
This would be ideal so that the Markdown name ends up in the Edit page. However, I don't think I should have to involve pandoc here
How in the heck do I get the edit page to default the markdown to vimwiki when editing a vimwiki extension?
file used: blah.vimwiki
# always include this:
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES
################### custom extension + renderer
# # Custom extension rendering
# ## References
# * file reference: /var/lib/gems/2.1.0/gems/github-markup-1.6.0/lib/github/markup/command_implementation.rb
# * [Adding Pandoc to Gollum - Martin Wolf's weblog [OUTDATED]](https://www.mwolf.net/2014/04/29/adding-pandoc-to-gollum/)
ci = ::GitHub::Markup::CommandImplementation.new(
/vimwiki/,
["Vimwiki"],
"pandoc -f markdown-tex_math_dollars-raw_tex",
:vimwiki)
# bind your own extension regex (the new set of extensions will also include `.asc` and `.adoc`):
# # * file reference: /var/lib/gems/2.1.0/gems/github-markup-1.6.0/lib/github/markups.rb
Gollum::Markup.register(:vimwiki, "Vimwiki")
Gollum::Markup.formats[:vimwiki][:regexp] = /vimwiki/
GitHub::Markup::markup_impl(:vimwiki, ci)
##################
Attempt to replace the Markdown primary extension and regex.
I don't understand why this isn't working unless I'm misunderstanding the order of operations for matching and overrides.
The page will display, the extension is recognized, but the page does not format at all -scrunches everything together.
# always include this:
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES
# Attempt to replace the primary extension for Markdown
# remove the original markdown binding:
Gollum::Markup.formats.delete(:markdown)
# and define your own
Gollum::Markup.formats[:thing] = {
:name => "Markdown",
:regexp => /thing/
}
Attempt to just replace the markdown extension regex
Same result as attempt 2.
The page will display but it is not formatted correctly
# always include this:
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES
Gollum::Markup.formats[:markdown][:regexp] = /vimwiki|thing/
I'm closing the question:
As it turns out there is no way easy way to use the markdown processor and also get the edit page to recognize that there is a different extension. The markdown processor requires the extension to be valid it it's regex of extensions found in markdown.rb.
The bottom line is that I would need to implement something similar to what pandoc is doing anyway. So I'm just going just drop the subject and stick with pandoc -'Things I've tried #1' from the original question.
Rather than take a bunch of space here I've posted the documentation on the project page with code examples
Thank you to whomever spent some time thinking about this.
scholdoc (see scholarlymarkdown.com) is a fork of pandoc that has !FINALLY! easy referencing of figures/code blocks etc. build in - a central missing piece in pandoc.
Is there any straight forward way to force usage of scholdoc instead of the shipped pandoc binary when using knitr/rmarkdown in rstudio?
When I set in .Rprofile
options(
rstudio.markdownToHTML = function(inputFile, outputFile) {
system(
paste(
"~/.cabal/bin/scholdoc",
shQuote(inputFile),
"-o", shQuote(outputFile)))
})
as indicated here, this seems to work, but, as it is missing all manner of command line options used by the internal pandoc, produces HTML out of the box and will lead me down a painful way of getting all the CLI options right.
After studying some rmarkdown code, I have also tried to set the environment variable RSTUDIO_PANDOC to contain the path of scholdoc - to no avail.
Can anyone point out an easy way to do this with up-to-date rstudio/scholdoc installations?
I asked this long ago an thought that for completeness sake, I'd point out, that bookdown has stepped into the arena to provide cross referencing of figures etc. within rmarkdown documents.
after issuing install.packages('bookdown'), RStudio may be coerced to use it by adding the following to the YAML header of a document:
output:
bookdown::pdf_document2:
Do you need to write a plugin for this or can you do it e.g. with the user.behaviors file?
Where can I find a tutorial and comprehensive documentation on this?
LightTable uses CodeMirror for syntax highlighting.
If the language you want is one of CodeMirrors existing modes (and it's in the version of the node module that your version of LightTable is using) then you should be able to use the set-syntax command (ctrl+space then type "syntax" to find it) to apply it to the current editor. You can add the following to your user.behaviors file to associate the syntax with a given file extension:
[:files :lt.objs.files/file-types [{:exts [:eg],
:mime "text/x-example",
:name "Example",
:tags [:editor.example]}]]
If a CodeMirror mode is not available, you'll first need to write one. Here are some docs on Writing CodeMirror Modes.
#RobinGower's answer works for me, eg for Jade syntax highlighting add [:files :lt.objs.files/file-types [{:name "jade" :exts [:jade] :mime "text/x-jade" :tags [:editor.jade]}] ] to the user.behaviors file
#mydoghasworms - have you already seen these pages?
LightTable FAQ page
getting started
I found a few helpful things on both.
How can I configure GitHub's Atom to make it automatically set a particular syntax highlighting to filenames based on name and/or extensions?
Specifically I want it to automatically set Ruby syntax highlightning to Cocoapods' Podfiles.
As of Atom 1.0.8 this is now possible without the file-types package, using a core feature. To achieve this, open the config.cson file, and add a section like the following:
"*":
# Other config
core:
customFileTypes:
"source.ruby": [
"Podfile"
]
There is guidance on finding the language scope name here: https://flight-manual.atom.io/using-atom/sections/basic-customization/#finding-a-languages-scope-name
This is now possible with the file-types third-party package. I used the following syntax:
"*":
# Other config
"file-types":
"^Podfile$": "source.ruby"
This should be placed in the config.cson file.
Here's an excerpt from the readme:
file-types package
Specify additional file types for languages.
Extension Matchers
Drop the dot before the extension to use extension matchers.
For example, you can associate .ex_em_el with text.xml in your config.cson
as follows:
'file-types':
'ex_em_el': 'text.xml'
RegExp Matchers
You can match with regular expressions, too. Most JavaScript regular
expressions should work; but, the system looks for a dot (.), a caret (^) at
the start, or a dollar ($) to identify RegExp matchers.
For example, you can associate /.*_steps\.rb$/ with source.cucumber.steps in
your config.cson as follows:
'file-types':
'_steps\\.rb$': 'source.cucumber.steps'
NOTE: Extension Matchers take priority over RegExp Matchers.
As of this writing, there is no way to do this short of submitting a PR to the language-ruby package or creating your own fork of the language-ruby package.
There is a bug tracking this issue here: https://github.com/atom/atom/issues/1718
Anyone arriving here looking to add support for template files in php e.g. .tpl, the folloing works in atom 1.10.2. I do not have previous versions so I can't say about earlier versions.
Add this in your config (config.cson) after core:. I added it after audioBeep: false line.
customFileTypes:
"text.html.php": [
"tpl"
]
Documentation made me go around in circles. Several articles wrongly mention source.php where as it should be text.html.php
Just getting started with atom coming from npp++ basically as I have struggled with snippet support there and hope atom can do a good job.
To add to Maurice Kelly's answer (my reputation is too low to comment)
This is now documented at:
https://github.com/atom/flight-manual.atom.io/blob/681c7fe6e69f1f64396ecadfde1323a01e7f5b96/book/02-using-atom/sections/06-customizing.asc