geany custom filetype .svrf for syntax highlighting - file-type

I have a similar issue;
I copied and edited filetype_extensions.conf in my ~/.config/geany adding:
CALIBRE=*.rul;*.svrf;*.SVRF;*.cal;
Then under ~/.config/geany/filedefs I created following files:
filetypes.CALIBRE.conf ==> my custom filetypes
filetypes.commmon ==> I wanted specific colored named_styles
# For complete documentation of this file, please see Geany's main documentation
[styling]
comment=svrf_comment
key=svrf_keyword_comment,bold
[settings]
# default extension used when saving files
extension=svrf
lexer_filetype=NONE
[keywords]
# all items must be in one line
svrf=EXT ENC INT EXPAND
# the following characters are these which a "word" can contains, see documentation
#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
# single comments, like / in this file
comment_single=//
# multiline comments
#comment_open=/*
#comment_close=*/
# set to false if a comment character/string should start at column 0 of a line, true uses any
# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d
#command_example();
# setting to false would generate this
# command_example();
# This setting works only for single line comments
comment_use_indent=true
# context action command (please see Geany's main documentation for details)
context_action_cmd=
[indentation]
#width=4
# 0 is spaces, 1 is tabs, 2 is tab & spaces
#type=1
[build-menu]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension
# (use only one of it at one time)
#FT_02_LB=_Lint
#FT_02_CM=jshint "%f"
#FT_02_WD=
#error_regex=([^:]+): line ([0-9]+), col ([0-9]+)
However when I open an svrf file type my custom filetypes is not recognized (no specific color while I chose some styling).
If I choose [styling=C] and lexer_filetype=C I am getting color for "C" code...
I also tried [styling] and lexer_filtype=NONE, but once again my custom highlight is not recognized.
I alread ready geany manual, as well as looked as some post but none of them is completely answering this subject (on the 2nd overflow link user has mapped to existing filetype hence he's not getting behavior he had wished).
geany custom filetype .sass for syntax highlighting
Geany: Syntax highlighting for custom filetype for SOME words
Do you have any idea on how to solve this issue?

Related

How pandoc lua filters can be used to add the title as the level-1 header?

I'd like to use pandoc lua filter when I convert multiple markdown files from markdown to pdf. I'd like the titles of individual markdown files to be used as chapters (first-level headers).
I learned the existing examples, and I think this one is close to what I need - basically I need to add pandoc.Header(1, doc.meta.title) to all my markdown files, however I'm struggling to write the lua filter and make it work.
I think this question is doing a similar action pandoc filter in lua and walk_block
The pandoc command:
pandoc -N --lua-filter add-title.lua blog/*.md --pdf-engine=xelatex --toc -s -o my_book.pdf
The add-title.lua (this is just wrong, no exceptions but nothing happens to the output):
function add_header (header)
return {
{Header = pandoc.Header(1, meta.title)}}
end
Input files:
1.md
---
title: Topic1
---
## Sample Header from file 1.md
text text text
2.md
---
title: Topic2
---
## Sample Header from file 2.md
text text text
Expected output equivalent to this markdown (but my final format is pdf)
---
title: Title from pandoc latex variable
---
# Topic1
## Sample Header from file 1.md
text text text
# Topic2
## Sample Header from file 2.md
text text text
I think the key problem is that the lua filters only run once the full set of documents have been parsed into a single AST. So the individual files are effectively concatenated prior to parsing to create a single document with a single set of metadata. The individual title settings in the yaml metadata blocks are being overridden before the filter has a chance to run. Assuming that you need to get the heading from each separate metadata block (and can't just put the header in directly) this means that you cannot let pandoc join the files. You will need to read and parse each file separately. Fortunately this is pretty easy with filters.
The first step is to make a single reference file that contains links to all of the other files.
---
title: Combined title
---
![First file](1.md){.markdown}
![Second file](2.md){.markdown}
Note that the links are specified using images with a special class .markdown. You could use some other method, but images are convenient because they support attributes and are easy to recognise.
Now we just need a filter that will replace these images with the parsed elements from the linked markdown file. We can do this by opening the files from lua, and parsing them as complete documents with pandoc.read (see https://www.pandoc.org/lua-filters.html#module-pandoc). Once we have the documents we can read the title from the metadata and insert the new header. Note that we apply the filter to a Para element rather than the Image itself. This is because pandoc separates Block elements from Inline elements, and the return value of the filter must be of the same type. An Image filter cannot return the list of blocks parsed from the file but a Para can.
So here is the resulting code.
function Para(elem)
if #elem.content == 1 and elem.content[1].t == "Image" then
local img = elem.content[1]
if img.classes:find('markdown',1) then
local f = io.open(img.src, 'r')
local doc = pandoc.read(f:read('*a'))
f:close()
-- now we need to create a header from the metadata
local title=pandoc.utils.stringify(doc.meta.title) or "Title has not been set"
local newHeader=pandoc.Header(1, {pandoc.Str(title)})
table.insert(doc.blocks, 1, newHeader)
return doc.blocks
end
end
end
If you run it on the combined file with
pandoc -f markdown -t markdown -i combined.md -s --lua-filter addtitle.lua
you will get
---
title: Combined title
---
Topic 1
=======
Sample Header from file 1.md
----------------------------
text text text
Topic 2
=======
Sample Header from file 2.md
----------------------------
text text text
as required.
Note that any other yaml metadata in the included files is lost. You could capture anything else by taking it from the individual meta object and placing it into the global one.

How to fix internal link issues when publishing a Docusaurus site on GitLab pages

In my Docusaurus project my internal links work on my local environment, but when I push to GitLab they no longer work. Instead of replacing the original doc title with the new one it adds it to the url at the end ('https://username.io/test-site/docs/overview/add-a-category.html'). I looked over my config file, but I do not understand why this is happening.
I tried updating the id in the front matter for the page, and making sure it matches the id in the sidebars.json file. I have also added customDocsPath and set it to 'docs/' in the config file, though that is supposed to be the default.
---
id: "process-designer-overview"
title: "Process Designer Overview"
sidebar_label: "Overview"
---
# Process Designer
The Process Designer is a collaborative business process modeling and
design workspace for the business processes, scenarios, roles and tasks
that make up governed data processes.
Use the Process Designer to:
- [Add a Category](add-a-category.html)
- [Add a Process or Scenario](Add%20a%20Process%20or%20Scenario.html)
- [Edit a Process or Scenario](Edit%20a%20Process%20or%20Scenario.html)
I updated the add a category link in parenthesis to an md extension, but that broke the link on my local and it still didn't work on GitLab. I would expect that when a user clicks on the link it would replace the doc title in the url with the new doc title ('https://username.gitlab.io/docs/add-a-category.html') but instead it just tacks it on to the end ('https://username.gitlab.io/docs/process-designer-overview/add-a-category.html') and so the link is broken as that is not where the doc is located.
There were several issues with my links. First, I converted these files from html to markdown using Pandoc and did not add front matter - relying instead on the file name to connect my files to the sidebars. This was fine, except almost all of the file names had spaces in them, which you can see in my code example above. This was causing real issues, so I found a Bash script to replace all of the spaces in my file names with underscores, but now all of my links were broken. I updated all of the links in my files with a search and replace in my code editor, replacing "%20" with "_". I also needed to replace the ".html" extension with ".md" or my project would no longer work locally. Again, I did this with a search and replace in my code editor.
Finally, I ended up adding the front matter because otherwise my sidebar titles were all covered in underscores. Since I was working with 90 files, I didn't want to do this manually. I looked for a while and found a great gist by thebearJew and adjusted it so that it would take the file name and add it as the id, and the first heading and add it as the title and sidebar_label, since as it happens that works for our project. Here is the Bash script I found online to convert the spaces in my file names to underscores if interested:
find $1 -name "* *.md" -type f -print0 | \
while read -d $'\0' f; do mv -v "$f" "${f// /_}"; done
Here is the script I ended up with if anyone else has a similar setup and doesn't want to update a huge amount of files with front matter:
# Given a file path as an argument
# 1. get the file name
# 2. prepend template string to the top of the source file
# 3. resave original source file
# command: find . -name "*.md" -print0 | xargs -0 -I file ./prepend.sh file
filepath="$1"
file_name=$("basename" -a "$filepath")
# Getting the file name (title)
md='.md'
title=${file_name%$md}
heading=$(grep -r "^# \b" ~/Documents/docs/$title.md)
heading1=${heading#*\#}
# Prepend front-matter to files
TEMPLATE="---
id: $title
title: $heading1
sidebar_label: $heading1
---
"
echo "$TEMPLATE" | cat - "$filepath" > temp && mv temp "$filepath"

\imagegraphics doesn't interpret \ escape in filename

I'm trying to insert a background image with the beamer package using the following:
\usebackgroundtemplate{%
\includegraphics[width=\paperwidth,keepaspectratio]{/path/to_file/background.png}%
}
The problem I'm having is that my background file path has an underscore in it, as I put in the example above. (This is my home directory on OS X, so I can't really change it.) When I generate this via pandoc the resultant latex file has the underscore escaped with a \, so it looks like this:
\usebackgroundtemplate{%
\includegraphics[width=\paperwidth,keepaspectratio]{/path/to\_file/background.png}%
}
but this makes it impossible for includegraphics to find the file and so it fails at that point.
If I manually remove the \ from the latex, or move the file to, say, the root directory, so that there is no underscore in the path, all is well. Here's the exact error:
LaTeX Warning: File `/Users/my\_name/Downloads/background.png' not fou
nd on input line 102.
! Package pdftex.def Error: File `/Users/my\T1\textunderscorename/Down
loads/background.png' not found: using draft setting.
So is there something I can do to tell includegraphics that the name is escaped, or to remove the escaping?
Here's the YAML:
---
name: John Doe
backgroundImage: /Users/my_name/Downloads/background.png
---
Text to add to template:
$if(backgroundImage)$
\usebackgroundtemplate{%
\includegraphics[width=\paperwidth]{$backgroundImage$}%
}
YAML values are interpreted as Markdown, unless specified otherwise. The backgroundImage is hence translated into LaTeX when used within $backgroundImage$.
The solution is to force literal interpretation of the input by telling pandoc that you know what you are doing, and that the input is already formatted as LaTeX:
---
name: John Doe
backgroundImage: '`/Users/my_name/Downloads/background.png`{=latex}'
---
This is based on the raw attribute extension, which is enabled by default for pandoc flavored Markdown.

What does ellipsis at end of .clang-format mean?

When running:
$ clang-format -style=Google -dump-config > .clang-format
The file is appended by a ellipsis (...).
TabWidth: 8
UseTab: Never
...
Does it have any significance? Can I delete it? Someone is asking what it means in a code review.
https://clang.llvm.org/docs/ClangFormatStyleOptions.html says:
The .clang-format file uses YAML format
http://www.yaml.org/refcard.html says:
'...': Document terminator.
Some more from http://yaml.org/spec/1.2/spec.html:
YAML uses three dashes (“---”) to separate directives from document
content. This also serves to signal the start of a document if no
directives are present. Three dots ( “...”) indicate the end of a
document without starting a new one, for use in communication
channels.

Atom text editor remove trailing whitespace on save

I use Sublime text. Now I am trying Atom. When I save any file in sublime text it does not include any trailing blank line. But saving any file in Atom leaves a trailing blank line. How do I force Atom not to leave trailing white spaces?
Under your Atom Preferences go to Packages tab and search for whitespace. Click on the whitespace package and uncheck Ensure Single Trailing Newline option
On global level this can be changed using settings in Whitespace package, but if you want to disable it for a specific language you have to use syntax-scoped properties in your config.cson.
'.text.html.php': # php overrides
whitespace:
ensureSingleTrailingNewline: false
removeTrailingWhitespace: false
'.source.ruby': # ruby overrides
whitespace:
ensureSingleTrailingNewline: false
removeTrailingWhitespace: false
To see the scope of language go to Packages tab and search for your language.
Click on the settings of the language package and you can see the scope:
Go to packages and find "whitespace", go to it's settings and uncheck the last checkbox.
Settings
Checkbox
To add to Dan Moldavan's answer.
I experienced this issue when working on a Rails Application.
I added a .editorconfig file with the following properties:
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
And I added a .gitattributes file with the following properties:
# Enforce Unix newlines
* text=auto eol=lf
And then my Atom Editor threw a problem:
1 problem affecting .gitattributes
whitespace: It is possible that the "whitespace"-package prevents the following properties from working reliably: insert_final_newline, trim_trailing_whitespace. You may try reconfiguring or disabling the "whitespace"-package to solve regarding issues.
Here's how I fixed it:
Open your Atom Editor
Go to Edit > Preferences > Packages
Type in whitespace
Click on the package that shows up
Untick the following:
Ensure Single Trailing Newline
Ignore Whitespace On Current Line
Leave Ignore Whitespace Only Lines unticked
Save and close the settings.
That's all.
I hope this helps

Resources