Alt+Space on a OSX causing defective code in HTML (Coda) - keyboard

Is it a known problem that unregular spaces used in code can cause a CSS or an HTML to be defective ?
When typing a bit fast, I sometimes type ALT+SPACE instead of SPACE (before the curly braces most of the time).
Is it possible to make all alternative spaces symbols (that are invisible to the eyes, but not to the code) be the standard space symbol ?

You can create your own custom key map, simply by creating a file under ~/Library/KeyBindings, named DefaultKeyBinding.dict. For your purpose the file needs to contain the following lines:
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
/* My custom Keybinds */
{
"~ " = ("insertText:", " "); /* Option + Space = Space */
}
Unfortunately this solution doesn't work for all programs since the bindings are depending on the Cocoa framework and even some of the applications using it do ignore some combinations (more information about the deficits can be found here, under "Caveat").
Additional Links:
http://xahlee.info/kbd/osx_keybinding.html
https://web.archive.org/web/20090404114150/http://www.cocoabits.com/KeyBindingsEditor/Manual/index.html (GUI tool)
About your HTML problem
It actually shouldn't cause any problems to use non-ASCII characters in HTML or CSS but using the wrong character set can lead to unwanted display effects. Without knowing the specific context I can't give any concrete diagnosis about that.

Related

Why does make use a back quote and single quote around the target name?

I found in all make warning / error messages, it uses a single back quote but then a single quote to highlight the user input.
For example, the error message of the undefined makefile name is like
Makefile `xxx' was not found.
At first I thought it was a typo, but it seems to me it is intended for all messages.
https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
It is distinct from the modern development to use both single / double quote around the highlight text, e.g. Makefile 'xxx' was not found.
Does anyone know the reason behind it?
I would guess it is a holdover from when fonts were displayed differently. For computer text that was intended to be read by humans, it used to be that (on many systems) using backquote/quote would produce output that resembles the way that English was normally typeset.
Consider for example: https://data.historicaltexts.jisc.ac.uk/view?pubId=bl-001973110&pageId=bl-001973110-660536-22 :
For other information, see for example:
discussion of "backtick-apostrophe" notation
Markus Kuhn's explanation of how the X Window System displayed fonts

Data structure for a grammar checker for LaTeX sources

Let me start with acknowledging that this is a rather broad question, but I need to start somewhere and reduce the design space a bit.
The problem
Grammarly is an online app that provides grammar and spell-checking as a browser plugin. Currently, there neither exists support for text editors nor latex sources. Grammarly is apparently often confused when forced to deal with annotated text or text that is formatted (e.g. contains wrapped lines). I guess many people could use that tool when writing up scientific papers or pretty much any other LaTeX tool. I also presume that other solutions exist or will soon pop up that work similarly.
The solution
In principle, it is not necessary to support Grammarly directly in, e.g., emacs. It suffices to provide a convenient interface to check multiple source files at once. To that end, a simple web app could walk through a directory, read all .tex sources, remove all formatting and markup, and expose the files as an HTML document. The user could open that document, run Grammarly, and apply any fixes. The app would have to take the corrected text and reapply formatting, markdown, etc. to save the now fixed source file.
The question(s)
While it is reasonably simple to create such a web application, there are other requirements to be considered: LaTeX parsing (up to "standard" syntax) and a library like HaTeX could deal with parsing and interpretation. But the process of editing needs some thought. Presuming that the removal of formatting can be implemented by only deleting content, it should be possible to take a correction as a diff and reapply it to the formatted document.
In Haskell, is there a data structure for text editing that supports this use case. That is, a representation of text that can store deletions, find diffs, undo deletions, and move a diff accordingly? If not in Haskell, does something like this exist somewhere else?
Bonus question 2: What is the simplest (as in loc required) web framework in Haskell to set up such a web app? It would serve one HTML document and accept updated versions of the text files. No database is required.
Instead of removing and then adding the text formatting, you could parse the souce text into a stream of annotated tokens:
data AnnotatedChar = AC
{ char :: Char
, formatting :: String
}
The following source:
Is \emph{good}.
would be parsed as:
[AC 'I' "", AC 's' "", AC ' ' "\emph{", AC 'g' "", ...
Then, extract only the chars from this list, send them to Grammarly, and get back the result. Now, diff the list of annotated characters with the list of characters you got from Grammarly. This way, you only to deal with a list of characters, but keep the annotations.

What is this "&" highlight error for PHP documents in Sublime Text?

Editor : Sublime Text 3
Does anyone knows what is that red highlight in the image above?
PHP error? editor(Sublime) error? or something else?
I'm working on a PHP project.
This is a known bug in the way Sublime Text currently highlights & characters that are part of a URL. See https://github.com/sublimehq/Packages/issues/428 for a discussion about it.
Basically, the problem is that, in HTML, & characters can't normally be used on their own, they are supposed to begin a reference to an "entity"/character. In HTML & is represented by & which stands for "ampersand", the name of this character. However, as per the above discussion, it seems to be valid in some circumstances inside URLs.
There are a couple of ways to "fix" the problem yourself.
One would be to modify your color scheme to not highlight scope invalid.illegal.bad-ampersand.html, but this would affect legitimate invalid uses.
Another would be to override the HTML syntax definition that ST uses to not mark the ampersand as invalid when inside a href etc. (this is the offending line.)
Probably the easiest solution is just to use & in place of & in your hrefs for now.

Skip $ character from normal text

This is very simple question but I unfortunately didn't get any clue to get rid from this error. I am writing a blog post about jquery ajax where I need to write a symbol $. I am using Mathjax for writing mathematical notation. As I write $ (for example $.getJSON), the Mathjax library decodes this as LaTeX commands. Anybody knows how to skip that $ character so that MathJax library behaves it as normal $?
By default, MathJax does not use the single dollar as a delimiter for in-line math (for exactly the reason you indicate), and so your configuration must be explicitly enabling it. See the text2jax dpcumentation for details of how this is done.
You have several options:
Remove the configuration that turns on dollar signs for in-line math. (This won't be good if you have already used them for in-line math in other posts)
Enable the processEscapes option so that you can use \$ to get a dollar without it being used as a math delimiter
If your blog allows you to enter raw HTML, you could use <span>$</span> to prevent MathJax from using the dollar as a delimiter (math can't contain HTML tags, so this dollar will not match up with another one, so won't be used as a delimiter).
Put your code examples inside <pre> or <code> containers, as MathJax (at least by default) doesn't process math within these. Your configuration may have changed that, however, so check the skipTags setting in your configuration.
Any of these should allow you to do what you need.

Intelligent file search for windows that can ignore whitespace and search in code?

Does anybody know a Windows based searching tool that is easy to use and is programmer
friendly.
The functions I am looking for:
Ignore white space in search
= capable to find
myTestFunction ( $parameter, $another_parameter, $yet_another_parameter )
{ doThis();
using the query
myTestFunction($parameter,$another_parameter,$yet_another_parameter){doThis();
without Regexes.
Search code "semantically" (for me, it would have to be PHP):
Search in comments only
Search in function names only
Search for parameters that are named $xyz
Search in (insert code construct here) only
If there is none around, it's high time somebody developed it! :)
I have opened a bounty for this.
See our SD Search Engine. This is a language-sensitive search engine designed to search large code bases, with special language classifiers for C, C++, Java, C#, COBOL, JavaScript, Ada, Python, Ruby and lot of other languages, including your specific target langauge PHP (PHP4 and PHP5).
I think it does everything you requested.
It indexes the language elements so search across large code bases are extremely fast (Linux Kernal ~~ 7.5 Million lines --> 2.5 seconds). (The indexing step runs
on Windows, but the display engine is in Java.)
Search hits are shown in one-line context hit window showing the file and line number, as well as the line with the hit highlighted. Clicks on hits bring up the source code, tabs expanded appropriately, and the line count right even for languages which have odd line counting rules (such as GCC WRT form characters), with the hit line and hit text highlighted. Clicking in the source window will launch your favorite editor on the file.
Because it understands language elements, it ignores language-specific whitespace. It skips over comments unless you insist they be inspected. Searches thus ignore whitespace, comments and lineboundaries (if the language thinks lineboundaries are whitespace, which is why there are langauge-specific scanners). The query language allows you to specify which language tokens you want (specific tokens in quotes, or generic tokens such as identifiers I, numbers N, strings S, operators O and punctuation P) with constraints on the token value as well as a series of tokens.
Your example search:
myTestFunction($parameter,$another_parameter,$yet_another_parameter){doThis();
would be expressed to the search engine precisely as:
I=myTestFunction '(' I ',' I ',' I ')' '{' I=dothis '(' ')' ';'
but it would probably be easier (less typing) to find it as:
I=myTest* ... I=dothis
where I=myTest* means an identifier starting with myTest and ... means "near".
The Search Engine also offer regular expressions searches on the text, if you insist.
So you still have grep-like searches (a lot slower than indexed searches)
but with the hit window and source display windows too.
I use ack really successfully for this kind of thing, particularly when trying to find things in large codebases. I run it linux myself but I don't see any reason why it won't run on windows or in Cygwin at the very least. Check it out, I think you'll find it is exactly what you're looking for.
Search code "semantically" (for me, it would have to be PHP):
For this you could (and I think should) use some custom code using token_get_all()
See also the available tokens
Ignore white space in search
A simple regex should be sufficient. It depends on your regex-library, but most come with a whitespace modifier/flag.
For my Windows desktop search, I use Agent Ransack. I use this as a replacement for the windows search.
You can use regular expressions, but there is a nice entry screen if you want to avoid entering them directly.
Take a look at Google Desktop API, it has very powerful set of methods to do what you're looking for.
Of course it requires you to have the Google Desktop installed.
After reviewing it a little, it provides some functionality but not that specific as what you require.
I really like Crimson Editor and it allows RegEx searches. It has helped me a bunch over the past six years. I think it will fit your needs. Try it.
I use TextPad for searching code files in Windows. It has a very handy find-in-files function (Search / Find In Files) and you can use regex which should meet any search requirements. In the search results it will list the file location, line number and a snippet from that line.

Resources