export: support %4 for code block css style url

This commit is contained in:
Le Tan 2018-05-14 20:42:02 +08:00
parent 8f24d38bf8
commit b355872c5f
3 changed files with 13 additions and 8 deletions

View File

@ -528,14 +528,14 @@ void VExportDialog::startExport()
QString outputFolder = QDir::cleanPath(QDir(getOutputDirectory()).absolutePath());
QString renderStyle = m_renderStyleCB->currentData().toString();
QString cssUrl = g_config->getCssStyleUrl(renderStyle);
QString renderCodeBlockStyle = m_renderCodeBlockStyleCB->currentData().toString();
s_opt = ExportOption(currentSource(),
currentFormat(),
(MarkdownConverterType)m_rendererCB->currentData().toInt(),
m_renderBgCB->currentData().toString(),
renderStyle,
m_renderCodeBlockStyleCB->currentData().toString(),
renderCodeBlockStyle,
m_subfolderCB->isChecked(),
ExportPDFOption(&m_pageLayout,
m_wkhtmltopdfCB->isChecked(),
@ -555,7 +555,8 @@ void VExportDialog::startExport()
m_customSrcFormatCB->currentData().toInt(),
m_customSuffixEdit->text(),
m_customCmdEdit->toPlainText(),
cssUrl,
g_config->getCssStyleUrl(renderStyle),
g_config->getCodeBlockCssStyleUrl(renderCodeBlockStyle),
m_customAllInOneCB->isChecked(),
m_customFolderSepEdit->text(),
m_customTargetFileNameEdit->text()));
@ -1304,7 +1305,8 @@ QWidget *VExportDialog::setupCustomAdvancedSettings()
QLabel *tipsLabel = new QLabel(tr("<span><span style=\"font-weight:bold;\">%0</span> for the input file; "
"<span style=\"font-weight:bold;\">%1</span> for the output file; "
"<span style=\"font-weight:bold;\">%2</span> for the rendering CSS style file; "
"<span style=\"font-weight:bold;\">%3</span> for the input file directory.</span>"),
"<span style=\"font-weight:bold;\">%3</span> for the input file directory; "
"<span style=\"font-weight:bold;\">%4</span> for the rendering code block CSS style file.</span>"),
this);
tipsLabel->setWordWrap(true);
@ -1336,7 +1338,7 @@ QWidget *VExportDialog::setupCustomAdvancedSettings()
// Cmd edit.
m_customCmdEdit = new QPlainTextEdit(this);
m_customCmdEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
QString cmdExamp("pandoc --resource-path=.:\"%3\" --css=\"%2\" -s -o \"%1\" \"%0\"");
QString cmdExamp("pandoc --resource-path=.:\"%3\" --css=\"%2\" --css=\"%4\" -s -o \"%1\" \"%0\"");
m_customCmdEdit->setPlaceholderText(cmdExamp);
m_customCmdEdit->setToolTip(tr("Custom command to be executed"));
m_customCmdEdit->setProperty("LineEdit", true);

View File

@ -167,12 +167,14 @@ struct ExportCustomOption
const QString &p_outputSuffix,
const QString &p_cmd,
const QString &p_cssUrl,
const QString &p_codeBlockCssUrl,
bool p_allInOne,
const QString &p_folderSep,
const QString &p_targetFileName)
: m_srcFormat(p_srcFormat),
m_outputSuffix(p_outputSuffix),
m_cssUrl(p_cssUrl),
m_codeBlockCssUrl(p_codeBlockCssUrl),
m_allInOne(p_allInOne),
m_folderSep(p_folderSep),
m_targetFileName(p_targetFileName)
@ -198,6 +200,8 @@ struct ExportCustomOption
QString m_cmd;
QString m_cssUrl;
QString m_codeBlockCssUrl;
bool m_allInOne;
QString m_folderSep;

View File

@ -174,13 +174,12 @@ static QString evaluateCommand(const ExportCustomOption &p_opt,
const QString &p_inputFolder,
const QString &p_output)
{
QString cssStyle = QDir::toNativeSeparators(p_opt.m_cssUrl);
QString cmd(p_opt.m_cmd);
replaceArgument(cmd, "%0", p_input);
replaceArgument(cmd, "%1", p_output);
replaceArgument(cmd, "%2", cssStyle);
replaceArgument(cmd, "%2", QDir::toNativeSeparators(p_opt.m_cssUrl));
replaceArgument(cmd, "%3", p_inputFolder);
replaceArgument(cmd, "%4", QDir::toNativeSeparators(p_opt.m_codeBlockCssUrl));
return cmd;
}