How to use Prettify with Pelican? - prettify

I would like to use prettify instead of Pelican's default code highligher on a Pelican site. I disabled the default code highlighting by specifying the MD_EXTENSIONS setting manually in pelicanconf.py and not including the codehilite extension. I've also successfully included prettify in the template.
The missing bit:
Prettify requires <code> or <pre> tags to have the attribute class="prettyprint", as explained here. How can I coerce Pelican to include this attribute by default?

I guess you have to edit theme it self.

For the following it is necessary to use version 2.6 (or later) of the Python-Markdown package.
In pelicanconf.py, add
MD_EXTENSIONS = [
'extra',
'codehilite(linenums=False,css_class=prettyprint,guess_lang=False,use_pygments=False)'
]
The two key settings are use_pygments=False, which will cause code-highlight to simply output <pre><code>... blocks, and css_class=prettyprint, which adds the required class to <pre> tags.
Now modify the Pelican theme according to prettify's setup instructions and you're set!

Related

Have VSCode ignore specific reference links in markdown validation

In Visual Studio Code with Markdown validation enabled (markdown.validate.enabled: true), I can ignore links to specific files that may not exist in the current context via the markdown.validate.ignoredLinks setting. However, that setting does not seem to apply to reference links (e.g. [link]: some-reference), nor can I find a corresponding setting specific to reference links.
Why do I want this? My specific use-case involves an extension the "standard" (CommonMark) markdown format to auto-generate a table-of-contents using the following syntax (and no, I don't expect VSCode to generate a preview of that TOC):
[[_TOC_]]
<!-- or -->
[TOC]
VScode happily generates a warning for such links, namely:
No link definition found: 'TOC' (link.no-such-reference)
Somewhat obviously, I can make the warning disappear I define a (bogus) TOC reference, such as:
[toc]: bogus
I can also disable validation of all reference links ("markdown.validate.referenceLinks.enabled": false), but I don't want to do that. I want to ignore the error for a specific reference, much like one can ignore a GLOB pattern for file links (markdown.validate.ignoredLinks).
Does anyone know of a such a setting before I submit a bug/missing-feature report?

TYPO3 / Fluid: Inline Viewhelper notation in Templates of FluidEmail

I’m using the new TYPO3\CMS\Core\Mail\FluidEmail feature of TYPO3 v10.3 to send HTML system e-mails. Unfortunately, I’m experiencing a weird behavior with Viewhelpers in the e-mail Templates. Calling the regular Viewhelper notation like e.g. <f:uri.resource extensionName="backend" path="Images/typo3_orange.svg"/> works as expected. But inline notations of the same Viewhelper (like {f:uri.resource(extensionName: 'backend', path: 'Images/typo3_orange.svg')}) don’t get processed at all.
Surprisingly, when I call the regular notation first and the inline notation afterwards in the same template, both notations get resolved.
I also experienced that no fluid variables are accessible in the template, e.g. {normalizedParams}, which should be available when you set the request like $message->setRequest($GLOBALS['TYPO3_REQUEST']);
Did anyone experience a similar behavior and has a hint for me?
Here's my implementation in my Controller Action:
$message = GeneralUtility::makeInstance(FluidEmail::class);
$message
->to($email)
->format(FluidEmail::FORMAT_HTML)
->setTemplate('MyTemplate')
->assign('pages', $pages);
if ($GLOBALS['TYPO3_REQUEST'] instanceof ServerRequestInterface) {
$message->setRequest($GLOBALS['TYPO3_REQUEST']);
}
GeneralUtility::makeInstance(Mailer::class)->send($message);
Reference: https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/10.3/Feature-90266-Fluid-basedTemplatedEmails.html
Sounds like a fluid parsing problem. Do you have any { or } flying around in your template that could mess up fluids parsing?
Just run into the same problem with one of my in-house plugins after switching from php7.2 to php7.4 (when switching back to php7.2 the resource path was resolved again correctly).
It turned out that some inline javascript using curly brackets further down the page was to blame (thank you Daniel). Putting it in a separate file solved the issue. It would appear that the use of inline JS is tolerated to different degrees depending on the php version being used.

Change label of flexform select item in TYPO3 extension tx_news

I want to add a new sorting option to the flexform in the frontend plugin of the TYPO3 extension tx_news. This works fine so far with these additions:
ext_tables.php of my theme extension:
$TYPO3_CONF_VARS['EXT']['news']['orderByNews'] .= ',archive';
TypoScript configuration within my theme extension:
plugin.tx_news.settings.orderByAllowed := addToList(archive)
What I miss now is the possibility to change the label of the new item archive in the select field Sort by of the flexform.
I assume it is done via page TSconfig and TCEFORM.tt_content.pi_flexform.news_pi1.sDEF.settings.orderBy but I can't figure out exactly how.
TYPO3 version is 6.2
This did the trick for me:
TCEFORM.tt_content.pi_flexform.news_pi1.sDEF.settings\.orderBy.altLabels.archive = LLL:EXT:my_theme/pathto.xlf:archive
It's important to escape the dot before the fieldname!
I never tried to use pageTS to localize (only template TS), so I don't know if it is actually possible. I would however suggest localizing the label using the locallang files, in this case creating locallang_db.xlf in appropriate path in typo3conf/l10n/ with localization for tx_news_domain_model_news.archive label.
More info here: https://wiki.typo3.org/Translations#Translation_internals.2C_how_does_it_work.3F

TYPO3 extension: how to find certain TS setting

I found in typo3 admin side(/typo3), you can have two ways to set up TS,
you can set up through template->root, I think TS here will affect the whole site.
you can set up through template->certain page, it will only affect this page.
So my question is:
If I want to find where(which page) has TS setting such as : code = LIST, how could I do?
Use Web > Template module it has tools, you can for an example use Template Analyzer for the search
Try querying the database in phpMyAdmin or similar. The following looks in Template Setup:
SELECT pid, config, constants
FROM sys_template
WHERE config LIKE '%code = LIST%'
Replace config with constants to look in Template Constants. pid is the page ID.
If it is not set in the TypoScript, it perhaps has been set in the plugin itself. Just check the plugin content element itself.
In the Template module, go to the page where the setting is in effect.
Use the TSOB (Typo Script Object Browser) to search for "list":
This must show you all TS for this page that contains "list".
If you don't see the setting you can run a cmd/ctrl-F Search over the entire results.
You would have to search for "[code] = LIST".
Which will lead you to the following entry:
Hovering over the label will produce the above tooltip. Copy the line number.
Now change to the Template Analyzer. Here, you can click through all cascading templates and search for the line number:
This is definitely the line that sets that value.
From the "Template hierarchy" tree you will easily find the template that contains the setting.

Tiny MCE Editor stripping code

I currently have my extended_valid_elements set up as follows.
using EPiServer.Editor.TinyMCE;
namespace Customer.Web.Templates.Plugins.TinyMCE
{
[TinyMCEPluginNonVisual(AlwaysEnabled = true, EditorInitConfigurationOptions = "{ extended_valid_elements: 'iframe[*]' }")]
public class ExtendedValidElements
{
}
}
However, I need to add the ability to enter an extra entry next to a link, as the tinyMCE is currently stripping it out.
I cant seem to get the syntax right without crashing the edit mode of the site... my logic would suggest 'iframe[*]','a[data-lightbox]' }")] should do the trick, but it doesn't. I just get an error.
Any ideas? Many Thanks.
Marc.
According to the TinyMCE documentation,
When adding a new attribute by specifying an existing element rule
(e.g. img), the entire rule for that element is over-ridden so be sure
to include all valid attributes not just the one you wish to add.
So try
EditorInitConfigurationOptions = "{ extended_valid_elements: 'iframe[*], a[name|href|target|title|data-lightbox]' }")]
I would consider using an asterisk in place of the word 'lightbox' to allow any data attribute to be used.
if that doesn't work, you can find more information at about valid_elements and extended_valid_elements on the TinyMCE site.
Hope this helps