Modifying word separators per scope - sublimetext2

I have a custom .tmLanguage file on Sublime Text that require certain word separators. Can I change the word separator per scope inside the same language?
I can change the separators using the .sublime-settings file, but it changes to the entire file.
Example:
On my language I have a special scope that contains all element inside a double square brackets ("[[ content ]]"). Inside that scope I need the char "/" to NOT be a word separator but I do want it on the rest of the file.

Related

write_html() method in fpdf not using font/encoding specified

I'm creating a PDF with a large collection of quotes that I've imported into python with docx2python, using html=True so that they have some tags. I've done some processing to them so they only really have the bold, italics, underline, or break tags. I've sorted them and am trying to write them onto a PDF using the fpdf library, specifically the pdf.write_html(quote) method. The trouble comes with several special characters I have, so I am hoping to encode the PDF to UTF-8. To write with .write_html(), I had to create a new class as shown in their readthedocs under the .write_html() method at the very bottom of the left hand side:
from fpdf import FPDF, HTMLMixin
class htmlFPDF(FPDF, HTMLMixin):
pass
pdf = htmlFPDF()
pdf.add_page()
#set the overall PDF to utf-8 to preserve special characters
pdf.set_doc_option('core_fonts_encoding', 'utf-8')
pdf.write_html(quote) #[![a section of quote giving trouble with quotations][2]][2]
The list of quotes that I have going into the pdf all appear with their special characters and the html tags (<u> or <i>) in the debugger, but after the .write_html() step they then show up in the pdf file with mojibake, even before being saved, as seen through debugger. An example being "dayâ€ÂTMs demands", when it should be "day's demands" (the apostrophe is curled clockwise in the quote, but this textbox doesn't support).
I've tried updating the font I use by
pdf.add_font('NotoSans', '', 'NotoSans-Regular.ttf', uni=True)
pdf.set_font('NotoSans', '', size=12)
added after the .add_page() method, but this doesn't change the current font (or fix mojibake) on the PDF unless I use the more common .write(text_height, quote) method, which renders the underline/italicize tags into the PDF as text. The .write() method does preserve the special characters. I'm not trying to change the font really, but make sure that what's written onto the PDF preserves the special characters instead of mojibake them.
I've also attempted some .encode/.decode action before going into the .write_html(), as well as attempted some methods from the ftfy library. And tried adding '' to the start of each quote to no effect.
If anyone has ideas for a way to iterate through each line on the PDF that'd be terrific, since then I could use ftfy to fix the mojibake. But ideally, it would be some other html tag at the start of each quote or a way to change the font/encoding of the .write_html() method, maybe in the class declaration?
Or if I'm at a dead-end and should just split each quote on '<', use if statements to detect underlines, italicize, etc., and use the .write() method after all.
Extract docx to html works really bad with docx2python. I do this few month ago. I recommend PyDocX. docx2python are good for docx file content extracting, not converting it into a html.

How To Simply Push A Variable To An HtmlService Template AS Html

I am using:
var template = HtmlService.createTemplateFromFile("MyForm.html");
Which contains a variable:
<?= defaultInnerHtml ?>
And I am trying to assign THIS variable with the content of another HTML file:
template.defaultInnerHtml
= HtmlService.createHtmlOutputFromFile(
"MyInnerHtml.html").getContent();
But the contents of MyInnerHtml.html become encoded: the angle brackets are replaced with entities etc. I am trying just to stuff some more Html inside the MyForm.html file before serving that back.
I can't see how to get just the raw contents to show up in place of the variable in the template.
Any help?
To disable this contextual escaping of special characters, change your template so it embeds the value of the variable like this:
<?!= defaultInnerHtml ?>
Note the exclamation mark. This specifies force-printing, which directs the template engine to embed the contents of the variable verbatim.
From Google's documentation:
Contextual escaping is important if your script allows untrusted user input. By contrast, you’ll need to force-print if your scriptlet’s output intentionally contains HTML or scripts that you want to insert exactly as specified.

Common-Lisp printing the tab character in function format

I wish to print the tab character with the format function. I can achieve this with ~C and then placing #\tab as an argument to format, but this seems a bit verbose as for a newline one can simply place a ~% in the string.
What is the most commonly used practise for printing tabs with the format function?
Thanks for all the help!
There is no notation for the tab character in FORMAT.
There are several choices, but none is really really good.
use #\tab (or a variable set to the character) as the argument, as you mention, is okay for me
embed a literal tab character in the string. This may break with some editor settings, where the editor replaces tabs with spaces. It's also not directly visible.
use a function in a format string, which writes a tab character
use a reader macro to introduce extended string syntax. Probably not bad. Maybe there exists even one. There was a post on comp.lang.lisp with an example.

Converting spaces to tabs in multiple files Sublime Text 2

Is there any way to convert all spaces to tabs, not file by file?
If I open a file and go through View => Indentation => Convert Indentation to Tabs, it only changes this file. I want to convert indentations to tabs in a whole project.
Use search and replace in multiple files to convert n spaces to tabs in select files.
First open find in files panel, cmd + shift + f, by default to find and replace in multiple files. Next define a regular expression to match spaces as tabs eg {4} (make sure you set Regular Expressions in the panel) for 4 spaces and replace with \t in desired files. Change {4} to however many spaces are being used for indentation.
As mentioned in comments to match spaces at the start of a line you can use the regexp ^( {4})+

Escape special (HTML tag) characters in XML attribute?

As part of an XML node attribute, I need to pass up HTML characters as part of an attribute value, such as hello" />. I can't use CDATA as part of the value of the node, as lots of other systems use this method and I cannot afford to break or rewrite that process, so I'm stuck with this.
I can't HTML encode the values, as they're used inside of an email and are subsequently outputted literally as HTML encoded values (<br >hello, for example).
Is there a way to escape HTML (specifically, the < character) and allow me to keep un-encoded HTML inline as an attribute? Thanks.
The XML characters <>&" must be escaped identical to the HTML entities < and so on. Using XML APIS will receive/store the original character. Other character entities in HTML should be converted to UTF-8. Numeric entities, hex (ü) and decimal (࣭) are simple, but for named entities (•) one needs a Library. (If one wants to achieve completeness.)