jqMath plugin to write equations

727 views
Skip to first unread message

Milind

unread,
Oct 1, 2013, 3:53:02 PM10/1/13
to tiddl...@googlegroups.com

I am using jqMath to display equations on my website, for example: http://www.amved.com/milindsweb/Input_Offset_for_Folded_Cascode_Diffamp_with_MOS_load.html

I am really interested to use jqMath on Tiddlywiki. Since the javascript is already there it might be a simple matter to make it into a tiddlywiki Extension. If that can be done it would be really great since jqMath is really easy to setup and the syntax is very intuitive, just like writing the equation directly and its faster than MathJax. I see this link: http://www.guyrutenberg.com/2011/06/25/latex-for-tiddlywiki-a-mathjax-plugin/ where the MathJax javascript is used as a extension to tiddlywiki. I am guessing it would be something similar. I have no knowledge at all about Javascript or Tiddlywiki extensions, if anyone thinks this is a easy thing to do I would appreciate some guidance. If a plugin for jqMath exists I would love to get a hold of it.

   After talking to the developer of jqMath he told me that we just have to load the stylesheet and the 2 javascript files and then when generating the HTML of the tiddler we need to call M.parseMath(myDiv); after loading the equation in myDiv element.

    Is there a template to do these things in Tiddlywiki so such kind of scripts can be easily integrated in your custom extension? That would be very useful. Any help would be appreciated.


Thanks.

David Bakin

unread,
Oct 1, 2013, 11:14:25 PM10/1/13
to tiddl...@googlegroups.com
Don't know the answer to your question ... but you're creating a cool site!  (I especially like your hand drawn circuit diagrams!  Nicely reminiscent of Forrest M Mims III!)

Milind

unread,
Oct 2, 2013, 1:19:17 AM10/2/13
to tiddl...@googlegroups.com
Thank you!

Eric Shulman

unread,
Oct 2, 2013, 4:01:38 AM10/2/13
to tiddl...@googlegroups.com
On Tuesday, October 1, 2013 12:53:02 PM UTC-7, Milind wrote:

I am really interested to use jqMath on Tiddlywiki. 

   After talking to the developer of jqMath he told me that we just have to load the stylesheet and the 2 javascript files and then when generating the HTML of the tiddler we need to call M.parseMath(myDiv); after loading the equation in myDiv element.


1) Create a tiddler called JQMath.css, and copy/paste the content from

2) Edit the TWCore StyleSheet tiddler (look in the "shadowed" tab), and append
      [[JQMath.css]]

3) Create a tiddler called JQMath.js, tagged with 'systemConfig', and copy/paste the content from

4) Edit the content of JQMath.js... very near the end, find this:
   M.parseMathQ=true;
and change it to
   M.parseMathQ=false;

5) Create a tiddler called JQMathPlugin, tagged with 'systemConfig', containing the following:
//{{{
config.macros.parseJQMath = {
   handler: function(place, tiddler, params) { M.parseMath(place); }
}
//}}}

6) To test, create a tiddler named JQMathTest, containing some JQMath syntax, followed by the <<parseJQMath>> macro, like this:
---------------
For these resistors, any mismatch in then causes a delta drop due to the tail current which would have to be balanced out in the input thus looking like an offset:
{{{$$V_{os1}g_{m2}/{1+g_{m2}R_1}R_1={ΔR_1I_T}/2$$}}}
where $g_{m2}/{1+g_{m2}R_1}R_1$ is the gain from the input to the source of the input pair of the diffamp
This gives us:
{{{$$V_{os1}={ΔR_1I_T}/{2R_1G_m}$$}}}
where $G_m=g_{m2}/{1+g_{m2}R_1}$ is the transconductance of the input pair with the resistor degeneration
<<parseJQMath>>
---------------

Note: Some math syntax may also be parsed and rendered as TWCore syntax (for example "R_1 is seen as a valid WikiWord, and becomes an automatic TiddlyLink).  This can cause JQMath to fail to recognize math syntax that is otherwise valid.  To prevent TiddlyWiki from pre-processing the math syntax, you can wrap the equation within *tripled* curly-braces, as shown in the above example (content copied from your site and then edited to add the {{{...}}})

and... just to make it SUPER DUPER EASY....

I just put together a simple TW document with the needed bits and pieces.  It's attached to this post (see JQMath.html).

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
JQMath.html

David Bakin

unread,
Oct 2, 2013, 10:57:35 AM10/2/13
to tiddl...@googlegroups.com
Good tip on the wikiword formatting - but I think another approach would be to use the DisableWikiLinksPlugin to disable automatic wikiwords to non-existent tiddlers. 
 
(You might remember this plugin since ... you wrote it!  I've been happily using it.)
 
-- David

Eric Shulman

unread,
Oct 2, 2013, 12:06:37 PM10/2/13
to tiddl...@googlegroups.com

On Wednesday, October 2, 2013 7:57:35 AM UTC-7, David Bakin wrote:
Good tip on the wikiword formatting - but I think another approach would be to use the DisableWikiLinksPlugin to disable automatic wikiwords to non-existent tiddlers. 
(You might remember this plugin since ... you wrote it!  I've been happily using it.)

Although this is true, I wanted to provide a minimal solution that did not rely on adding other plugins to the document.

Nonetheless, DisableWikiLinksPlugin does have several ways to turn off linking that could be used in this instance.

* disable ALL automatic linking in ALL tiddlers
* disable automatic links only for non-existing tiddlers
* disable automatic links for tiddlers tagged with "excludeWikiWords"

Of these, I think that disabling links only for non-existing tiddlers makes sense, since the "links" in math syntax are unlikely to match any real tiddler titles in the document, but it would still allow use of automatic WikiWord linking, without needing to use brackets ([[...]]) to force links between tiddlers.

Milind Gupta

unread,
Oct 2, 2013, 4:46:21 PM10/2/13
to tiddl...@googlegroups.com
Thank you very much for giving the solution directly and also how you got there, this is very helpful. Since I already had the DisableWikiLinksPlugin I assumed I would not need the triple braces but the parsing does not work properly even when I disable all wiki links, probably because the disable wiki links acts on it after it has gone through the parse Math plugin??

It works great if I add the curly braces.


Thanks again,
Milind




--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/PNXaylx1HRY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.

Tobias Beer

unread,
Oct 3, 2013, 8:58:01 AM10/3/13
to tiddl...@googlegroups.com
Hi Milind & David,
 
Don't know the answer to your question ... but you're creating a cool site!  (I especially like your hand drawn circuit diagrams!  Nicely reminiscent of Forrest M Mims III!)

How does this site actually work?
I don't see much TiddlyWiki javascript running.
Are you leveraging some server side? Which and how?

I thought it might be GieWiki but then that does ship with all the core js.

- tobias

Milind

unread,
Oct 3, 2013, 9:17:44 AM10/3/13
to tiddl...@googlegroups.com
Hi Tobias,
      I write down my content in tiddlywiki and then use the snapshot plugin to export the tiddlers as separate HTML files. I then run a Lua script to transform the pages to my final HTML site pages. So it is like a 2 step publishing system. The transformation from the snapshot HTML to the final web page needs a template page and a configuration file to customize the pages.

Milind
--

Tobias Beer

unread,
Oct 3, 2013, 10:33:00 AM10/3/13
to tiddl...@googlegroups.com, Milind
Hi Milind,
 
I write down my content in tiddlywiki...

Would that be one or multiple?
 
and then use the snapshot plugin to export the tiddlers as separate HTML files.

Too bad it's not quite functional directly on TiddlyTools. Will do some testing of how it works.
 
I then run a Lua script to transform the pages to my final HTML site pages.

I assume this can't be done in TW beforehand.
 
So it is like a 2 step publishing system. The transformation from the snapshot HTML to the final web page needs a template page and a configuration file to customize the pages.

Is it that your Lua script is splitting one big snapshot file into individual pages while embedding the chunks into some template and then saving individual html files?
 
- tobias

Milind Gupta

unread,
Oct 3, 2013, 11:28:22 AM10/3/13
to Tobias Beer, tiddl...@googlegroups.com
On Thu, Oct 3, 2013 at 7:33 AM, Tobias Beer <beert...@gmail.com> wrote:
Hi Milind,
 
I write down my content in tiddlywiki...

Would that be one or multiple?
-- Each page on the website is a separate tiddler on the tiddlywiki.
 
and then use the snapshot plugin to export the tiddlers as separate HTML files.

Too bad it's not quite functional directly on TiddlyTools. Will do some testing of how it works.
 
I then run a Lua script to transform the pages to my final HTML site pages.

I assume this can't be done in TW beforehand.
-- The snapshot plugin does not generate the links of the table of contents plugin properly. Nor does it export all the linked files/images to a separate directory so that it can be made independent and portable as a chunk of files that can just be uploaded as a website. 
     Then I want to add social media tags like that for facebook, linkedin etc. Also I can add ads. These things are done and customized by the template and configuration file so it can be very flexible and by just tweaking the template and configuration file you can get a entirely different site. 
      It may be possible to do all these things in the snapshot plugin and it also allows custom css, but I have no experience or idea on how to write or use those things so I wrote the script in Lua. So it also allows anyone using it to add a plugin function to my script to do almost anything with the pages. 
       I was thinking to make the script open source but it seemed that people who use tiddlywiki are familiar with writing extensions and dealing with css so I saw no requirement for it.
 
 
So it is like a 2 step publishing system. The transformation from the snapshot HTML to the final web page needs a template page and a configuration file to customize the pages.

Is it that your Lua script is splitting one big snapshot file into individual pages while embedding the chunks into some template and then saving individual html files?
 -- The lua script just reads each HTML file generated for each tiddler by the snapshot plugin and then repairs the table of contents, relocated all the linked files and fixes their links,  then it does all the customizations that I have specified in the configuration file. All this content is placed in the template HTML file that I provide.
 
- tobias

Milind Gupta

unread,
Oct 3, 2013, 11:31:36 AM10/3/13
to Tobias Beer, tiddl...@googlegroups.com
As another example of this system see this website: http://www.amved.com/karm/wiki/index.html.
This site uses almost the same template as my site here but uses a different configuration file.

Milind

Reply all
Reply to author
Forward
0 new messages