I'm using the tool "Escape Tool" from the default Solr toolkit. I use it to display text fields that might have html tags embedded in them. I do this at the velocity UI document level. I.e. I escape it right before it displays.
I want to turn on highlighting, and have successfully done so via solrconfig:
<str name="hl">false</str>
<str name="hl.fl">*</str>
<str name="hl.usePhraseHighlighter">true</str>
<str name="hl.requireFieldMatch">true</str>
<str name="hl.regex.maxAnalyzedChars">10000</str>
<str name="hl.useFastVectorHighlighter">true</str>
Unfortunately, the escape tool escapes the default tag (em) so it doesn't really work the way its intended. Moving the escape procedure before the highlighting takes place sounds like the optimal solution. I'm not too familiar with the order things are applied by the UI on output.
One way to do it is to escape the fields on insertion: http://velocity.apache.org/engine/devel/webapps.html using org.apache.velocity.app.event.implement.EscapeHtmlReference. But I was wondering if there was a way to do it without modifying the content stored?
Thanks!
You could use a different highlight tag, e.g use something very unlikely in the input
<str name="hl.simple.pre">:-:${</str>
<str name="hl.simple.post">}:-:</str>
and then replace that back to your preferred highlight tag (e.g. <em>)
Related
In Visual Studio Code, in HTML mode, when I type in a square bracket ([) and then an alphabet ([s), the editor displays autocompletion for <div s="|">|</div>.
In other words, the bracket ([) followed by a character tries to autocomplete a <div> element with the given attribute.
I don't want to have this feature, since it slows down my typing as I am trying to write articles for some JavaScript internals that heavily use things like [[Prototype]], [[Writable]] and so on.
Is there any way to turn this feature off in HTML?
As per the docs you can use this setting:
"emmet.showExpandedAbbreviation": "never"
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.
I am trying to create an Html Editor. For this I am using JEditorPane, in which I want to read input from the JEditorPane character by character and want them to be stored in a string. For example: if user types <h so I want to read those two characters and according to those characters I will suggest users for the tags, in this case <html>,<header>,<head> etc (i.e. all tags starting with 'h'). So I am not getting how and which function to use to read character from JEditorPane as soon as user inputs into the JEditorPane.
So I am not getting how and which function to use to read character from JEditorPane as soon as user inputs into the JEditorPane.
You can use a DocumentListener Read the section from the Swing tutorial on How to Write a DocumentListener for more information and examples.
If you are creating an editor, which just displays the text, not the actual formatting, then you should use a JTextArea or a JTextPane. A JEditorPane is really only for displaying existing HTML files.
Keylistener worked for me. Using keylistener we can get input key strokes by the user.
I want to indent my text in the article I am writing in docbook 5. I also need to add colors to my text. Is that possible? If so how? I tried indenting as follows but it was not visible when I took the html output of it.(Here I tried to align the text "Kerfun" to the center) I have no idea regarding the colour change. Can someone please tell me how? Where have I gone wrong?
<dbk:para text-indent="center">Kerfun</dbk:para>
<dbk:para text-indent="center">
<dbk:emphasis role="bold">Fadiah</dbk:emphasis>
</dbk:para>
You haven't specified your OS or toolchain.
To format your xml:
I'd suggest using the "xmllint -format" command
To validate your xml:
Same command could be used to ensure your document is valid against the docbook schema
To colorize your xml:
That very much depends on what editor you use. Personally I'm a fan of gvim which has XML high-lighting enabled by default.
Update
As stated I'm not a windows guy but 2 minutes of googling lead me to the following:
Notepad++ appears to have an XML plugin. Source was the following link
I am using the wysiwyg editor TinyMCE and I have stripped out most of the functions to create a simpler version. However, I need the make the formatting as basic as possible as well, e.g., instead of <p> tags i need to use <br /> tags. Also, I would like it to not convert ' in ’ as I will be using the output in Flash.
The only editing tools still left in it are bold, italic, underline and link/unlink.
You can enforce the use of <br> with the configuration option force_br_newlines and you can define the encoding with the configuration option entity_encoding.
entity_encoding: "raw"
force_br_newlines: true,