Skip to content

Commit

Permalink
Merge branch 'master' into better_figures_and_images
Browse files Browse the repository at this point in the history
  • Loading branch information
dflock committed Oct 19, 2013
2 parents 7240f05 + 3ba3bf1 commit 2bd9481
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
26 changes: 26 additions & 0 deletions assets/Readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ The above will produce a minified and gzipped JS file:
Pelican's debug mode is propagated to Webassets to disable asset packaging
and instead work with the uncompressed assets.

If you need to create named bundles (for example, if you need to compile SASS
files before minifying with other CSS files), you can use the ``ASSET_BUNDLES``
variable in your settings file. This is an ordered sequence of 3-tuples, where
the 3-tuple is defined as ``(name, args, kwargs)``. This tuple is passed to the
`environment's register() method`_. The following will compile two SCSS files
into a named bundle, using the ``pyscss`` filter:

.. code-block:: python
ASSET_BUNDLES = (
('scss', ['colors.scss', 'main.scss'], {'filters': 'pyscss'}),
)
Many of Webasset's available compilers have additional configuration options
(i.e. 'Less', 'Sass', 'Stylus', 'Closure_js'). You can pass these options to
Webassets using the ``ASSET_CONFIG`` in your settings file.
Expand All @@ -76,5 +89,18 @@ LessCSS's binary:
ASSET_CONFIG = (('closure_compressor_optimization', 'WHITESPACE_ONLY'),
('less_bin', 'lessc.cmd'), )
If you wish to place your assets in locations other than the theme output
directory, you can use ``ASSET_SOURCE_PATHS`` in your settings file to provide
webassets with a list of additional directories to search, relative to the
theme's top-level directory. For example:

.. code-block:: python
ASSET_SOURCE_PATHS = (
'vendor/css',
'scss',
)
.. _Webassets: https://github.com/miracle2k/webassets
.. _Webassets documentation: http://webassets.readthedocs.org/en/latest/builtin_filters.html
.. _environment's register() method: http://webassets.readthedocs.org/en/latest/environment.html#registering-bundles
12 changes: 12 additions & 0 deletions assets/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,21 @@ def create_assets_env(generator):
for item in generator.settings['ASSET_CONFIG']:
generator.env.assets_environment.config[item[0]] = item[1]

if 'ASSET_BUNDLES' in generator.settings:
for name, args, kwargs in generator.settings['ASSET_BUNDLES']:
generator.env.assets_environment.register(name, *args, **kwargs)

if logging.getLevelName(logger.getEffectiveLevel()) == "DEBUG":
generator.env.assets_environment.debug = True

if 'ASSET_SOURCE_PATHS' in generator.settings:
# the default load path gets overridden if additional paths are
# specified, add it back
generator.env.assets_environment.append_path(assets_src)
for path in generator.settings['ASSET_SOURCE_PATHS']:
full_path = os.path.join(generator.theme, path)
generator.env.assets_environment.append_path(full_path)


def register():
"""Plugin registration."""
Expand Down
35 changes: 21 additions & 14 deletions latex/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,28 @@

from pelican import signals

# Reference about dynamic loading of MathJax can be found at http://docs.mathjax.org/en/latest/dynamic.html
# The https cdn address can be found at http://www.mathjax.org/resources/faqs/#problem-https
latexScript = """
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type= "text/javascript">
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML"],
TeX: { extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"], equationNumbers: { autoNumber: "AMS" } },
extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js"],
tex2jax: {
inlineMath: [ [\'$\',\'$\'] ],
displayMath: [ [\'$$\',\'$$\'] ],
processEscapes: true },
"HTML-CSS": {
styles: { ".MathJax .mo, .MathJax .mi": {color: "black ! important"}}
}
});
<script type= "text/javascript">
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'https:' == document.location.protocol ? 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js' : 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
s[(window.opera ? "innerHTML" : "text")] =
"MathJax.Hub.Config({" +
" config: ['MMLorHTML.js']," +
" jax: ['input/TeX','input/MathML','output/HTML-CSS','output/NativeMML']," +
" TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } }," +
" extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']," +
" tex2jax: { " +
" inlineMath: [ [\'$\',\'$\'] ], " +
" displayMath: [ [\'$$\',\'$$\'] ]," +
" processEscapes: true }, " +
" 'HTML-CSS': { " +
" styles: { '.MathJax .mo, .MathJax .mi': {color: 'black ! important'}} " +
" } " +
"}); ";
(document.body || document.getElementsByTagName('head')[0]).appendChild(s);
</script>
"""

Expand Down

0 comments on commit 2bd9481

Please sign in to comment.