diff --git a/CHANGELOG.md b/CHANGELOG.md index dd7dbf07d..6dbaa228a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,31 @@ ### Fixed +## [0.9.5-alpha.6] - 2024-03-01 + +### Added + +* Add option to the run configuration settings to run LaTeX commands before compiling the main file +* Autocompletion for compiler arguments in run configuration settings +* Support a local Zotero instance in the remote libraries tool window via the BBT plugin +* Support Zotero groups in the remote libraries tool window +* Support local BibTeX files in the remote libraries tool window +* Improve file filters for the LaTeX package index +* Improve \DescribeMacro handling for the package doocumentation index +* Automatically translate HTML from the clipboard to LaTeX, by @jojo2357 +* Add option to disable indentation of environments, by @slideclimb + +### Fixed + +* Fix exception #2976 +* Fix exception #3469 +* Avoid line breaks when reformatting in the middle of commands, math and words +* Fix exception #3274 in the equation preview +* Never use jlatexmath for the TikZ preview +* Destroy invalid tokens for the remote libraries tool windows +* Fix missing folding for commands in math environments, by @jojo2357 +* Fix an issue when inlining files with whitespace, by @jojo2357 + ## [0.9.5-alpha.4] - 2024-02-28 ### Added @@ -368,11 +393,12 @@ Thanks to @jojo2357 and @MisterDeenis for contributing to this release! * Fix some intention previews. ([#2796](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2796)) * Other small bug fixes and improvements. ([#2776](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2776), [#2774](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2774), [#2765](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2765)-[#2773](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2773)) -[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5-alpha.4...HEAD -[0.9.5-alpha.4]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5-alpha.3...v0.9.5-alpha.4 -[0.9.5-alpha.3]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5-alpha.2...v0.9.5-alpha.3 -[0.9.5-alpha.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.4...v0.9.5-alpha.1 +[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5-alpha.6...HEAD [0.9.5-alpha.2]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5-alpha.1...v0.9.5-alpha.2 +[0.9.5-alpha.1]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.4...v0.9.5-alpha.1 +[0.9.5-alpha.3]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5-alpha.2...v0.9.5-alpha.3 +[0.9.5-alpha.4]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5-alpha.3...v0.9.5-alpha.4 +[0.9.5-alpha.6]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.5-alpha.4...v0.9.5-alpha.6 [0.9.4]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.3...v0.9.4 [0.9.3]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.3...v0.9.2 [0.9.2]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.1...v0.9.2 diff --git a/Writerside/topics/Run-configuration-settings.md b/Writerside/topics/Run-configuration-settings.md index 027d3b773..7e471d349 100644 --- a/Writerside/topics/Run-configuration-settings.md +++ b/Writerside/topics/Run-configuration-settings.md @@ -123,6 +123,34 @@ You can use for example the `TEXINPUTS` environment variable to include LaTeX fi For example `TEXINPUTS=/path/to/directory//:`, where `//` means that LaTeX (and TeXiFy) will search in any subdirectory of `/path/to/directory` for the file to be included, and `:` means to include the standard content of `TEXINPUTS`. For Windows, it is similar: `TEXINPUTS=C:...\path\to\directory\\;` (note the semicolon). For more information about paths resolving, see [https://www.tug.org/texinfohtml/kpathsea.html#Path-searching](https://www.tug.org/texinfohtml/kpathsea.html#Path-searching) +## LaTeX code to run before compiling the main file +_Since b0.9.5_ + +You can enter LaTeX code to be executed before the main file. +For example, suppose you want to have two versions of a document, then you could create two run configurations and use this field to set a boolean flag to a different value. + +For example, if your LaTeX file contains + + +``` +\documentclass{article} +\usepackage{etoolbox} + +% Only sets the value of \waarde if it is undefined +\providecommand{\waarde}{true} + +% Create a boolean and set it to the value of \waarde +\newbool{binair} +\setbool{binair}{\waarde} + +\begin{document} + \ifbool{binair}{waar}{onwaar} +\end{document} +``` + +then you can put `\newcommand{\waarde}{false}` in this field in your run configuration to set the value of the boolean to `false`. +This works for at least pdflatex, lualatex, xelatex and latexmk. + ## Custom SumatraPDF path See [(Windows) Choose a custom path to SumatraPDF](PDF-viewers.md#portable-sumatrapdf). diff --git a/gradle.properties b/gradle.properties index a5a15f0cb..22dd877fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 0.9.5-alpha.4 +pluginVersion = 0.9.5-alpha.6 # Info about build ranges: https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html # Note that an xyz branch corresponds to version 20xy.z and a since build of xyz.* diff --git a/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixExpressionSelector.kt b/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixExpressionSelector.kt index f81c11088..3d215e417 100644 --- a/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixExpressionSelector.kt +++ b/src/nl/hannahsten/texifyidea/editor/postfix/LatexPostfixExpressionSelector.kt @@ -9,6 +9,9 @@ import nl.hannahsten.texifyidea.psi.* import nl.hannahsten.texifyidea.util.parser.firstParentOfType import nl.hannahsten.texifyidea.util.parser.inMathContext +/** + * This class is also used by https://github.com/xylo/intellij-postfix-templates/blob/idea-232/src/de/endrullis/idea/postfixtemplates/languages/latex/LatexPostfixTemplateProvider.java + */ class LatexPostfixExpressionSelector(private val mathOnly: Boolean = false, private val textOnly: Boolean = false) : PostfixTemplateExpressionSelector { override fun hasExpression(context: PsiElement, copyDocument: Document, newOffset: Int): Boolean { diff --git a/src/nl/hannahsten/texifyidea/run/compiler/LatexCompiler.kt b/src/nl/hannahsten/texifyidea/run/compiler/LatexCompiler.kt index 87e28e57b..268279ea9 100644 --- a/src/nl/hannahsten/texifyidea/run/compiler/LatexCompiler.kt +++ b/src/nl/hannahsten/texifyidea/run/compiler/LatexCompiler.kt @@ -348,7 +348,21 @@ enum class LatexCompiler(private val displayName: String, val executableName: St .forEach { command.add(it) } } - command.add(mainFile.name) + // Run some code before running the document + if (runConfig.beforeRunCommand?.isNotBlank() == true) { + if (runConfig.compiler == LATEXMK) { + // latexmk has its own flag to do this + command.add("-usepretex=" + runConfig.beforeRunCommand) + command.add(mainFile.name) + } + else { + // pdflatex, lualatex and xelatex support this by being able to run on a given string as if it was in a file + command.add(runConfig.beforeRunCommand + " \\input{${mainFile.name}}") + } + } + else { + command.add(mainFile.name) + } return command } diff --git a/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt b/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt index 9a5310dbb..026705dc9 100644 --- a/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt +++ b/src/nl/hannahsten/texifyidea/run/latex/LatexRunConfiguration.kt @@ -68,6 +68,7 @@ class LatexRunConfiguration( private const val PDF_VIEWER = "pdf-viewer" private const val VIEWER_COMMAND = "viewer-command" private const val COMPILER_ARGUMENTS = "compiler-arguments" + private const val BEFORE_RUN_COMMAND = "before-run-command" private const val MAIN_FILE = "main-file" private const val OUTPUT_PATH = "output-path" private const val AUXIL_PATH = "auxil-path" @@ -99,6 +100,7 @@ class LatexRunConfiguration( } var environmentVariables: EnvironmentVariablesData = EnvironmentVariablesData.DEFAULT + var beforeRunCommand: String? = null var mainFile: VirtualFile? = null set(value) { @@ -277,6 +279,9 @@ class LatexRunConfiguration( // Read environment variables environmentVariables = EnvironmentVariablesData.readExternal(parent) + val beforeRunCommandRead = parent.getChildText(BEFORE_RUN_COMMAND) + beforeRunCommand = if (beforeRunCommandRead.isNullOrEmpty()) null else beforeRunCommandRead + // Read main file. val filePath = parent.getChildText(MAIN_FILE) setMainFile(filePath) @@ -373,6 +378,7 @@ class LatexRunConfiguration( parent.addContent(Element(VIEWER_COMMAND).also { it.text = viewerCommand ?: "" }) parent.addContent(Element(COMPILER_ARGUMENTS).also { it.text = this.compilerArguments ?: "" }) this.environmentVariables.writeExternal(parent) + parent.addContent(Element(BEFORE_RUN_COMMAND).also { it.text = this.beforeRunCommand ?: "" }) parent.addContent(Element(MAIN_FILE).also { it.text = mainFile?.path ?: "" }) parent.addContent(Element(OUTPUT_PATH).also { it.text = outputPath.virtualFile?.path ?: outputPath.pathString }) parent.addContent(Element(AUXIL_PATH).also { it.text = auxilPath.virtualFile?.path ?: auxilPath.pathString }) diff --git a/src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt b/src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt index 0e6e40331..a5f5d47e8 100644 --- a/src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt +++ b/src/nl/hannahsten/texifyidea/run/latex/ui/LatexSettingsEditor.kt @@ -11,6 +11,7 @@ import com.intellij.openapi.roots.ProjectRootManager import com.intellij.openapi.ui.* import com.intellij.openapi.util.SystemInfo import com.intellij.ui.EditorTextField +import com.intellij.ui.RawCommandLineEditor import com.intellij.ui.SeparatorComponent import com.intellij.ui.TitledSeparator import com.intellij.ui.components.JBCheckBox @@ -42,8 +43,9 @@ class LatexSettingsEditor(private var project: Project?) : SettingsEditor> private lateinit var enableCompilerPath: JBCheckBox private lateinit var compilerPath: TextFieldWithBrowseButton - private lateinit var compilerArguments: EditorTextField + private lateinit var compilerArguments: LabeledComponent private lateinit var environmentVariables: EnvironmentVariablesComponent + private lateinit var beforeRunCommand: LabeledComponent private lateinit var mainFile: LabeledComponent> private lateinit var outputPath: LabeledComponent> @@ -93,11 +95,13 @@ class LatexSettingsEditor(private var project: Project?) : SettingsEditor