I'm currently writing an application that uses Pygments to perform syntax highlighting. The problem I'm having is any code I process with Pygments has the leading and trailing whitespace in the file removed, and a single line break added to the end. Is there a way to make Pygments preserve the whitespace?
Preserving whitespace with Pygments
596 Views Asked by cpaul37 At
1
There are 1 best solutions below
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in SYNTAX-HIGHLIGHTING
- In VScode, How to custom the PHP heredoc tag "HTML" to others?
- How to highlight comments in several different colors in CLion?
- To enable syntax highlighting with color for JBehave stories in Eclipse
- Implement Highlight.js in TextArea
- How do I turn off syntax highlighting in micro text editor?
- How to fix broken syntax highlight in Visual Studio 2022 UI (different colors)
- Visual Studio 2022 - Strange C++ Coloring/Highlighting
- syntax highlighting in Visual Studio 2022 in cshtml files not working
- Vscode shows fake import errors when saving a file | Java
- How to change background color of selected code
- treesitter/highlighter issues with LaTeX formula in Markdown files, and any other language
- C language server on Zed for SDL
- Vue 3.4 same-name shorthand vs-code support
- Syntax highlighting not applied to PascalCase-named files
- VScode Latex: Disable syntax highlighting for a range of lines
Related Questions in PYGMENTS
- Sphinx: custom Pygments' lexer not found
- Pygments style less accurate than Ace editor theme
- why doesn't pygments discover my custom lexer after installation
- Crossbar and Pygments
- Change background color of output cell in JupyterLab
- Django - create code blocks in html templates
- Disable stripping of trailing newlines from code blocks
- No valid lexer class found error when testing custom Pygments lexer
- Why GNU Global doesn't index Pascal files of a project?
- Any Pygments lexer for the Mustache templating language?
- "pygmentize: command not found" Even though I already installed pygments on my system
- pygments highlight print in jupyter
- How to highlight whole syntax(including every modules's Keywords,class,etc.) of python in text widget in python tkinter
- Showing the line numbers in <pre> in Django project using Pygments
- Highlighting the inner code blocks in Django Template Engine with django-pygmentify
Related Questions in TRAILING-WHITESPACE
- How to remove trailing whitespace from jinja template with multiple strings separated by spaces?
- Can't add space before and after the list numbering
- How do I stop Selenium from trimming the space at the end of my string?
- Docx4j docx toPdf don't preserve whitespaces
- Force empty <span> to next line when wrapping occurs
- Remove white spaces from a KQL string: Kusto
- CSS `overflow-wrap: break-word;` applied to sequence of whitespaces
- Why are trailing spaces being added during inserting values into a table variable? Why is using the TRIM() function on just one row trimming all rows?
- Removing trailing whitespace for a tic tac toe board in python
- using rsync include exclude patterns matches whitespace
- Clear trailing spaces after pasted number in Angular
- Pyspark code giving wierd whitespace error
- Website has some trailing space, or overflow
- React Native Text Trailing Space
- Is it 100% safe to strip trailing whitespace from .c/.h source files?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I think you want to make your own lexer, e.g.
and explicitly pass it to
pygment.highlight. See the lexers' reference here.