Atom Editor Syntax Highlighting for ini files as Java Properties - syntax-highlighting

I am using Atom 1.33.0 on MacOS X 10.13 High Sierra
To configure atom to recognize files with the extension ".ini" as Java Properties and apply the appropriate syntax highlighter I checked the following links:
GitHub Atom: How to apply a particular syntax highlighting to some files based on name
https://discuss.atom.io/t/how-do-i-make-atom-recognize-a-file-with-extension-x-as-language-y/26539
https://flight-manual.atom.io/using-atom/sections/basic-customization/#finding-a-languages-scope-name
https://stackoverflow.com/a/51321435/6204861
https://discuss.atom.io/t/using-customfiletypes-to-change-the-language-for-html/40230
and assumed that the following config.cson would work:
"*":
core:
telemetryConsent: "no"
themes: [
"atom-light-ui"
"atom-light-syntax"
]
customFileTypes:
'source.Java Properties': [
'ini'
]
...
unfortunately this does not have the desired effect.
To find the correct name i opened an example Java Properties ".ini" file as "Plain Text". Then I changed the syntax highlighting manually to "Java Properties" by clicking in the bottom right corner. Then I pressed Alt-CMD-P which showed:
So "source.java-properties" should be the correct name.
I modified config.cson accordingly to:
"*":
core:
telemetryConsent: "no"
themes: [
"atom-light-ui"
"atom-light-syntax"
]
customFileTypes:
'source.java-properties': [
'ini'
]
And still it does not work.
What needs to be changed to make it work?

the coffeescript parser seems to be very picky about details
The following config.cson works:
"*":
core:
customFileTypes:
"source.java-properties": [
"ini"
]
disabledPackages: [
"welcome"
]
...

Related

Sphinx rst2pdf and role directives

In a reStructuredText on Sphinx 2.x, I want to put a content that changes depending on the output format.
In any source document, say, index.rst, add the following lines:
.. role:: pdf(raw)
:format: pdf
.. role:: latex(raw)
:format: latex
.. role:: html(raw)
:format: html
.. |foo| replace::
:pdf:`PDF!`
:latex:`LaTeX!`
:html:`HTML!`
I am |foo|
I expect it shows "I am HTML!" when the output format is in HTML, "I am LaTeX!" if it's LaTeX (even after converting the product to PDF via pdflatex) and "I am PDF!" if it's PDF.
I make the HTML version using make html and I see only "I am HTML!" in a web browser as I expect:
Install rst2pdf. Put the following lines in conf.py:
extensions = [
'rst2pdf.pdfbuilder'
]
pdf_documents = [(
'index',
u'testRst2Pdf',
u'Test Title',
u'Sarah Author')]
Make the PDF version with
sphinx-build -b pdf ./source/ ./build/
Update. Below is the output. No error. I ran this using WSL 1 (Ubuntu 18.04).
Running Sphinx v2.4.3
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [pdf]: targets for 1 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
processing testRst2Pdf...
index
resolving references...
done
writing testRst2Pdf...
done
build succeeded.
I see "I am PDF! LaTeX! HTML!" that includes all the three items.
Is there any way to get either "I am PDF!" or "I am LaTeX!" in the PDF file?
Note.
Before reporting this behavior as a bug, someone help me check if it's unexpected behavior or as-designed.
This question is derived from the other I asked earlier: StackOverflow: "Sphinx: Use a different directive for a different output format".
rst2pdf does not really have conditionals, but you might find the --strip-elements-with-class switch useful? Put the optional pieces into a class name and then if that class doesn't make sense for this format, remove it with the switch.
Manual is here https://rst2pdf.org/static/manual.html#command-line-options and I also blogged (basically a longer version of this first paragraph) about this https://rst2pdf.org/static/manual.html#command-line-options if more information would be useful.

Bash: Add languages to Chromium

Is it possibe to use Bash to add languages to Chromium? That is, do the equivalent of going to Settings - Advanced - Languages in the Chromium GUI, activate the languages you want, and then activate spell-checking for the same languages? Had a look at this, but there doesn't seem to be anything that fits the bill.
Figured it out. The best way seems to be to add a Python block to read and manipulate the Preferences-file using the JSON library. Before you do anything, you need to get your bearings in the Preferences-file. What are the relevant elements that you need to change?
If you go to Preferences in the Chromium GUI, you can see that there are two relevant settings:
1) Languages:
2) Dictionaries (for spell check):
These can be found in the Preferences-file by pretty-printing the file in the terminal (improving it with pygmentize) or saving a pretty-printed output to a file:
less Preferences | python -m json.tool | pygmentize -g
or
~/.config/chromium/Default$ less Preferences | python -m json.tool >> ~/Documents/output.txt
Searching through the file for language settings, you will find two relevant elements:
"intl": {
"accept_languages": "en-US,en,nb,fr-FR,gl,de,gr,pt-PT,es-ES,sv"
},
and
"spellcheck": {
"dictionaries": [
"en-US",
"nb",
"de",
"gr",
"pt-PT",
"es-ES",
"sv"
],
"dictionary": ""
}
Before you do anything else, it is wise to backup the Preferences-file... Next,you can alter the language settings by adding the following python-block to the bash script:
python - << EOF
import json
import os
data = json.load(open(os.path.expanduser("~/.config/chromium/Default/Preferences"), 'r'))
data['intl'] = {"accept_languages": "en-US,en,nb,fr-FR,gl,de,pt-PT,es-ES,sv"}
data['spellcheck'] = {"dictionaries":["en-US","nb","de","pt-PT","es-ES","sv"],"dictionary":""}
with open(os.path.expanduser('~/.config/chromium/Default/Preferences'), 'w') as outfile:
json.dump(data, outfile)
EOF
In this case, the script will remove Greek from the available languages and the spellchecker. Note that in order to add languages, you need to know the language code accepted by Chromium.
You can find more on reading and writing JSON here and here, and more on how to include Python scripts in bash scripts here.

Enabling the `todo` feature in sphinx docs

I am trying to use todo feature, I found a link on sphinx-docs and the following syntax
.. todo::
but it says that I need to set the todo_include_todos to True, as by default it is False, which file I need to update to get in enabled?
I found another SO post Sphinx todo box not showing but don't think it mentions the file where I need to set the config.
sphinx.ext.todo is a Sphinx extension which can be enabled by adding it to the list of extensions in your conf.py:
extensions = [
'extname',
'sphinx.ext.todo',
]
Once enabled, you need to configure it by setting the value todo_include_todos to True, also in your conf.py:
# Display todos by setting to True
todo_include_todos = True
Theme support for todos varies.
See also http://www.sphinx-doc.org/en/stable/config.html#confval-extensions
Note that the configuration option can also be overridden on the command line, which may make it easier to quickly expose or hide "to do"s according to the target audience. I believe booleans have to be passed as 0 or 1 in this case...
sphinx-build -b html -D todo_include_todos=1 -c docs docs build/html
or
python -m sphinx -b html -D todo_include_todos=1 -c docs docs build/html

ruby 1.9.3 build in sublime text 2

I'm searching for a correct .sublime-build for ruby 1.9.3
so far i'm not been able to use gems with the ones i tried
a way to launch my .rb file with the terminal with a shortcut from ST2 should be great for me to
thank you
There are two possible ways, one involves editing the exec.py file that comes with ST2 so that the build process is not piped/captured but i had no luck in this, maybe someone with a python background can ?
The other method works for me, i edit the "c:\users\user\AppData\Roaming\Sublime Text 2\Packages\Ruby\Ruby.sublime-build" file that also comes with ST2 and change the contents to this.
I have no problem to use gems that are installed correctly like this.
{
"cmd": ["ruby", "$file"],
"shell": true,
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby, source.rb, source.rbw",
"variants":
[
{
"name": "Run",
"cmd": ["start", "ruby", "$file"],
"selector": "source.ruby, source.rb, source.rbw"
}
]
}
After that you can run Ruby scripts in two ways, the normal one with F7 and in the console with Ctrl-Shift-B (from Build). In order to avoid that the window closes after execution you need to end your script with a system 'pause'. In begin/rescue blocks it would also be best to put this command.
So a script would look like this
puts "test"
system 'pause'
EDIT: add the option "Open Command Window Here.." to the context-menu
First create and put the following in the file
c:\users\user\AppData\Roaming\Sublime Text 2 \Packages\User\opencommand.py
import sublime, sublime_plugin
import subprocess
import os
class OpenPromptCommand(sublime_plugin.TextCommand):
def run(self, edit):
dire = os.path.dirname(self.view.file_name())
retcode = subprocess.Popen(["cmd", "/K", "cd", dire])
def is_enabled(self):
return self.view.file_name() and len(self.view.file_name()) > 0
Then open C:\Users\user\AppData\Roaming\Sublime Text 2\Packages\Default\Context.sublime-menu and at the end add
{ "caption": "-", "id": "file" },
{ "command": "open_prompt", "caption": "Open Command Window Here…" },
{ "command": "open_dir", "caption": "Open Containing Folder…" },
{ "caption": "-", "id": "end" }
From now on you can right-click in a open script and open explorer or the command prompt in the folder where the script is saved.
in macOS the equivalent to windows start is open... ie:
Windows
start . (opens windows explorer at current path)
Mac
open . (opens finder at current path)

What kind of syntax is this (yaml, ini, ...)?

Could anybody help me figure out the syntax of the code below?
"AddonInfo"
{
"name" "Addon name"
"version" "Current Version"
"up_date" "Date of update"
"author_name" "Addon's Author"
"author_email" ""
"info" "Addon's Info"
"override" "0"
}
It's a Half-Life 2 (to be specific, garrys mod) Configuration File. I think it's only used by the source engine.
Edit:
A simple regexp to convert to JSON:
config_str.gsub(/(")\s*"(.*?)"/, '\1: "\2",').gsub(/(".*?")\s*{/, '\1: {')
Where gsub is the function for global replacement.
Probably just a custom configuration file used by whatever system you're currently looking at?
JSON would have colons as Josh has pointed out

Resources