Mathjax formula is not showing properly on show page - ruby-on-rails

I'm using CKEditor as rich text editor. For mathematical formulas I included MathJax plugin. The problem is, when I insert formula in editor's panel - it's working and showing properly, for example, but in show page it's rendering only this, for example: \(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\). What should I do?

The MathJax plugin for ckeditor only converts a TeX string inside the Editor into a readable equation. The original source will still be the TeX string, and if you only put that content in your page - you will see the TeX string: \(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\) (as in your example).
The easiest way to "solve" this is to add the MathJax script to your page (not the editor), which will translate the TeX parts in your html to the readable equations:
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
Here is a working example:
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
</script>
<div>The next line should be displayed as equation (and not just string) if the MathJax was loaded correctly:</div>
<div style="margin: 20px;">
\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)
</div>

Related

TCPDF not render tabs space with <pre> tag

I'm using TCPDF to render a simple HTML that mainly have the data between "pre" tag. All is fine except when I have text separated by tabs spaces. Then the text is misaligned and don't show the text aligned.
I'm testing the first sample code.
https://tcpdf.org/examples/example_001/
Then I replace:
$html = <<<EOD
<pre>
RESEARCH LIST
XX-Name: Notes:
10-Progress Get +20
20-Research Get +2
27-Advanced Research Get +5
28-Atmospheric Converters Terraforming +1
29-Comet Ds Terraforming +4
</pre>
EOD;
I get the PDF but the text isn't aligned with columns.
If I open as .html is aligned correctly.
<HTML>
<HEAD>
<TITLE>XYZ</TITLE>
</HEAD>
<body>
<PRE>
DC-Name: Notes:
10-Progress Get +20
20-Research Get +2
27-Advanced Research Get +5
28-Atmospheric Converters Terraforming +1
29-Comet Ds Terraforming +4
</PRE>
</body>
</HTML>
What is wrong?
Salut,
Josep M

HTML parsing and extracting text

There are a number of resources to parse HTML pages and extract textual content. Jsoup is an example. In my case, I would like to extract the textual content tagged with the html tags under which each sentence occurs. For example, take this page
<html>
<head><title>Test Page</title>
<body>
<h1>This is a test page</h1>
<p> The goal is to extract <b>textual content <em> with html tags</em> </b> from html pages.
</body>
</html>
I'm expecting the output to be like this:
<h1>This is a test page</h1>
<p> The goal is to extract <b>textual content <em> with html tags</em> </b> from html pages.
In other words, I want to include specific html tags within the textual content of the page.
To get your result you can use this:
final String html = "<html>"
+ "<head><title>Test Page</title>"
+ "<body>"
+ "<h1>This is a test page</h1>"
+ "<p> The goal is to extract <b>textual content <em> with html tags</em> </b> from html pages."
+ "</body>"
+ "</html>";
// Parse the String into a Jsoup Document
Document doc = Jsoup.parse(html);
Elements body = doc.body().children();
// Do further things here ...
System.out.println(body);
Instead of the String html you can load a file or a website too - jsoup provides this all.
In this example body contains the html you posted as result.
Or do you need to select something like "h1 followed by p tag"?
However you may take a look at the Jsoup Selector API
You do it in two steps. First, as you have described, create a DOM tree using JSoup. Then process it using an XSL filter. In the XSL filter you can extract only those tags you are interested.

jquery mobile fullcalendar prev next icon

When using the jquery fullcalendar plugin (http://arshaw.com/fullcalendar/) with jquery mobile, the prev and next month button icons only show the arrow-up background image, which is the very first icon on the long 256 by 240 .png image file. When I refresh the page in Firefox, the correct arrow east and west show up, yet I lose all other styles including background, themes, etc. Refresh does not work in IE.
I searched high and low for an answer to this relatively minor issue. Here I believe may be the causes:
1. jquery ui and jquery mobile conflict (order of .js and .css files) --I tried all orders to no avail.
2. calling fullcalendar theme on mobile page (inside of page instead of head tags)
3. transition issue from home to specific mobile page
4. pixel size of ui-icon css class (should it be larger than 16px by 16px for mobile?)
5. need of a custom override of jquery ui using the $(document).ready() function.
Please see my included files head code below:
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar/fullcalendar.css'>
<link rel='stylesheet' type='text/css' href='../fullcalendar/demos/cupertino/thememobile.css'>
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar/fullcalendar.print.css' media='print'>
<link rel="stylesheet" href="jquery.mobile-1.0.1.min.css" />
<script src="jquery-1.6.4.min.js"></script>
<script src="jquery.mobile-1.0.1.min.js"></script>
<script type='text/javascript' src='../fullcalendar/jquery/jquery-ui-1.8.17.custom.min.js'></script>
<script type='text/javascript' src='../fullcalendar/jquery/jquery-1.7.1.min.js'></script>
<script type='text/javascript' src='../fullcalendar/fullcalendar/fullcalendar.min.js'></script>
<script type='text/javascript' src='../fullcalendar/fullcalendar/jquery.qtip-1.0.0-rc3.min.js'></script>
<script type='text/javascript' src='../fullcalendar/fullcalendar/calendareventsmobile.js'></script>
Any answer or brainstorming of answers will be very helpful.
Thanks in advance!
Have you tried using the FullCalendar with the theme option set to true? This forces it to use the jQuery UI theme instead of the fullCalendar theme. Maybe the CSS conflicts might go away then.
From the documentation...
A hash must be supplied that maps button names (from the header) to icon strings. The icon strings determine the CSS class that will be used on the button. For example, the string 'circle-triangle-w' will result in the class 'ui-icon-triangle-w'.
I was looking to use ui-icon-carat-1-w and ui-icon-carat-1-e. I found firebug to be very helpful in determining the correct hash value to use to get the proper mapping.
This is an example of what I needed to use.
buttonIcons: {
prev: 'carat-1-w',
next: 'carat-1-e'
},

How display and edit HTML in iOS

With UIWebView, I can display HTML very well. With UITextView, I can edit HTML. With what can I both display and edit HTML?
Is there any open source project or tutorial available?
You can show your html inside a UIWebView with a WYSIWYG editor inside. There are a lot of WYSIWYG editors out there. I like CKEditor (demo).
See the Developer Documentation - Integration for how to set / get the text of the WYSIWYG editor.
How to Create the WYSIWYG Editor:
Download the script files and bundle them in your app
Include the script (from ckeditor website)
<head>
...
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
</head>
Add text area with your initial text
<textarea id="editor1" name="editor1">
<p>Initial value.</p>
</textarea>
Create editor using javascript
<script type="text/javascript">
CKEDITOR.replace( 'editor1' );
</script>
How to get Text from WYSIWYG Editor
Use the script:
var editor_data = CKEDITOR.instances.editor1.getData();
You can use UIWebView's stringByEvaluatingJavaScriptFromString: method to run javascript code to get / set the html content as needed.
Have you tried using the UITextViewDelegate method (such as textViewDidChange:) and reload the content of the UITextView's text property back into the UIWebView (using loadHTMLString:baseURL:)?
- (void)textViewDidChange:(UITextView *)textView {
[self.webView loadHTMLString:textView.text baseURL:nil];
}
This will allow you to manually amend HTML and see the result.
check this lib which is updated and can be used above ios 11 and written in swift
-AztecEditor
link
-updated version of
RichEditorView
link

Printing in IE8 Has #href contents inline

Can someone tell me how to stop IE8 printing the value of the href for an A tag next to the text. For example this markup
Some Link
When printed comes out as
Some Link(/site/page.html)
when printed. How can I stop this?
This doesn't happen for me in IE8 and I've never spotted it. I also can't find it in the Internet Options anywhere.
It is possible that you have some software on your computer that does this, for example AVG Anti-Virus adds content to web pages to tell you that it has checked the links being displayed for potentially harmful content - so your system-security software may be expanding all links to show you where they actually point, to prevent phishing attacks.
If you do have some anti-phishing software on your machine, you'll have to find the option within that.
Update - It is almost certainly some clever CSS.
I have created the following test page to demonstrate how you can add the URL to a link using CSS generated content. If this was used within a print stylesheet, this would explain how the URL is getting added to the link when you are printing the page. To stop this, you would have to save a copy of the web page, remove the style rule from the print-only style sheet and then open your copy and print it!
<html>
<head>
<title>Test</title>
<style type="text/css">
a:after {
content: " [" attr(href) "] ";
}
</style>
</head>
<body>
<h1>Test</h1>
<p>This is a test to see if this
Link Shows A URL</p>
</body>
</html>

Resources