DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:xhtmlruby

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revision
plugin:xhtmlruby [2009-10-26 20:50]
86.89.151.209
plugin:xhtmlruby [2017-11-03 17:23]
MilchFlasche [Bugs] script.js (addInitEvent, cssRule.selector)
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Converts Japanese 漢字(ふり) into xhtml 1.1 <ruby><rb>漢字</rb><rp>(</rp><rt>ふり</rt><rp>)</rp></ruby> markup+description: Converts Japanese furigana written as 漢字(ふり) into XHTML 1.1 <ruby><rb>漢字</rb><rp>(</rp><rt>ふり</rt><rp>)</rp></ruby> markup
 author     : Mike "Pomax" Kamermans author     : Mike "Pomax" Kamermans
 email      : pomax@nihongoresources.com email      : pomax@nihongoresources.com
 type       : Action type       : Action
-lastupdate : 2009-10-26+lastupdate : 2010-10-14
 compatible : 2009-02-14b (not tested on earlier versions) compatible : 2009-02-14b (not tested on earlier versions)
 tags       : ruby, furigana tags       : ruby, furigana
 +
 +downloadurl: http://projects.nihongoresources.com/downloadables/plugin-xhtmlruby.tar.gz
 ---- ----
  
Line 15: Line 17:
 Download and install the plugin using the [[plugin:plugin|Plugin Manager]] using the following URL. Download and install the plugin using the [[plugin:plugin|Plugin Manager]] using the following URL.
  
-  * [[http://pomax.nihongoresources.com/downloads/plugin-xhtmlruby.tar.gz|tar.gz format (3k)]]+  * [[http://projects.nihongoresources.com/downloadables/plugin-xhtmlruby.tar.gz|tar.gz format (3k)]] FIXME Link not available (as at 12-Sep-2013) 
 +  * [[http://sites.google.com/site/seifer03/index/dokuwiki_xhtmlruby.zip|zip format (3k)]], Temp Mirror :!:
  
 To install the plugin manually, download the source to your plugin folder, ''lib/plugins'', and extract its contents.  That will create a new plugin folder, ''lib/plugins/xhtmlruby'', containing four file: To install the plugin manually, download the source to your plugin folder, ''lib/plugins'', and extract its contents.  That will create a new plugin folder, ''lib/plugins/xhtmlruby'', containing four file:
  
   * style.css - CSS styling for the ruby markup   * style.css - CSS styling for the ruby markup
-  * conf.ini - an ini file for setting whether to parse wiki text or not, and ToC text or not.+  * conf.ini - an ini file for setting whether to parse wiki text or not, and TOC text or not.
   * script.js - a script that ensures the CSS styling is correct for the browser that's loading the page   * script.js - a script that ensures the CSS styling is correct for the browser that's loading the page
   * action.php - the plugin   * action.php - the plugin
Line 72: Line 75:
 <ruby><rb>駅前</rb><rp>(</rp><rt>まえ</rt><rp>)</rp></ruby> <ruby><rb>駅前</rb><rp>(</rp><rt>まえ</rt><rp>)</rp></ruby>
 </code> </code>
- 
-**Note**: this is an action plugin, so you can use guide text in headings as well as base wiki text.  
  
  
Line 98: Line 99:
 ===== Bugs ===== ===== Bugs =====
  
-None known at the time of writing.+<del>None known at the time of writing.</del> 
 + 
 +Unfortunately, on my 2017 Frusterick Manners, this plugin causes <code> 
 +ReferenceError: addInitEvent is not defined 
 +addInitEvent(function(){ fixRubyAlignment(); }); 
 +js.php?...3892c5d (line 65824)</code> 
 + 
 +I have changed ''addInitEvent'' on the last line of script.js to ''jQuery'' (per suggestion on [[plugin:cellbg#compatibility_issues]] although I don't know the reason), but then it's found that on Line 29 ''cssRule.selectorText'' is also not defined... 
 + 
 +So finally I decided to: 
 +  - remove script.js in the plugin folder 
 +  - disable the plugin 
 +  - re-enable it again 
 +-> seems no problem so far, the action.php and the CSS file still do their jobs. I know that script.js can deal some compatibility problems across browsers, but I don't have the ability to debug it. --- [[user>MilchFlasche|MilchFlasche]] //2017-11-03 17:11//
 ===== Source ===== ===== Source =====
  
Line 149: Line 163:
  * XHTML 1.1 Ruby markup suffers from the "browsers don't always bother to obey CSS" problem.  * XHTML 1.1 Ruby markup suffers from the "browsers don't always bother to obey CSS" problem.
  * The standard way to visualise ruby is by making the ruby code an inline table, and bottom  * The standard way to visualise ruby is by making the ruby code an inline table, and bottom
- * aligning it. However, not all browsers understand "bottom". or "baseline". This JavaScript+ * aligning it. However, not all browsers understand "bottom". or "baseline". This javascript
  * will try to make sure the ruby placement is correct for all major browsers by detecting the  * will try to make sure the ruby placement is correct for all major browsers by detecting the
  * browser, and modifying the ruby CSS rules accordingly.  * browser, and modifying the ruby CSS rules accordingly.
Line 156: Line 170:
  */  */
  
-// ---------------------------------------------------------------------+// ----------------------------------------------------------------------------------------------------------------------
 // CSS MANIPULATION // CSS MANIPULATION
 // //
 // based on http://www.hunlock.com/blogs/Totally_Pwn_CSS_with_Javascript // based on http://www.hunlock.com/blogs/Totally_Pwn_CSS_with_Javascript
-// ---------------------------------------------------------------------+// ----------------------------------------------------------------------------------------------------------------------
  
-/** +function getCSSRule(ruleName, deleteFlag) {
-  * returns an associated object with stylesheet -> rule entries. The reason for this is +
-  * that returned rules alone are not enough; the user may need to perform actions based on +
-  * the stylesheet media type or href for instance. +
-  *  +
-  * If no matching rules were found at all, 'false' is returned +
-  */ +
-function getCSSRule(ruleName, deleteFlag) +
-{+
  ruleName=ruleName.toLowerCase();  ruleName=ruleName.toLowerCase();
  if (document.styleSheets) {  if (document.styleSheets) {
- // iterate through all stylesheets + for (var i=0; i<document.styleSheets.length; i++) { 
- for (var sheet=0; sheet<document.styleSheets.length; sheet++) + var styleSheet=document.styleSheets[i]; 
- + var ii=0;
- var styleSheet=document.styleSheets[sheet]; +
- var rule=0;+
  var cssRule=false;  var cssRule=false;
- do + do { 
- + if (styleSheet.cssRules) { cssRule = styleSheet.cssRules[ii]; } 
- if(styleSheet.cssRules) { cssRule = styleSheet.cssRules[rule]; } + else { cssRule = styleSheet.rules[ii]; } 
- else if (styleSheet.rules) { cssRule = styleSheet.rules[rule]; } + if (cssRule)  { 
- if (cssRule && cssRule.selectorText.toLowerCase()==ruleName) { return cssRule; } + if (cssRule.selectorText.toLowerCase()==ruleName) 
- rule++; + if (deleteFlag=='delete') { 
- } while (cssRule); + if (styleSheet.cssRules) { styleSheet.deleteRule(ii);
-+ else { styleSheet.removeRule(ii);
-+ return true; } 
- return false; + else { return cssRule; }}
-}+ ii++; 
 + } 
 + while (cssRule) }} 
 + return false;
 + 
 +function killCSSRule(ruleName) { return getCSSRule(ruleName,'delete');
 + 
 +function addCSSRule(ruleName) { 
 + if (document.styleSheets) { 
 + if (!getCSSRule(ruleName)) { 
 + if (document.styleSheets[0].addRule) { document.styleSheets[0].addRule(ruleName, null,0); 
 + else { document.styleSheets[0].insertRule(ruleName+' { }', 0); }}
 + return getCSSRule(ruleName); }
  
-// -------------------+// ----------------------------------------------------------------------------------------------------------------------
 // Ruby alignment code // Ruby alignment code
-// -------------------+// ----------------------------------------------------------------------------------------------------------------------
  
 /** /**
Line 200: Line 216:
 function getBrowser() function getBrowser()
 { {
- var opera="opera"; var ie="ie"; var gecko="gecko"; var browser="unknown";+ var opera="opera"; var ie="ie"; var gecko="gecko"; var chrome = "chrome"; var browser="unknown";
  if (window.opera) { browser = opera; }  if (window.opera) { browser = opera; }
  else if (Array.every) { browser = gecko; }  else if (Array.every) { browser = gecko; }
  else if (document.all) { browser = ie; }  else if (document.all) { browser = ie; }
 + else if (window.chrome) { browser = chrome; }
  return browser;  return browser;
 } }
Line 221: Line 238:
  // Opera (9.5x) is even more annoying. Neither "bottom" nor "baseline" does what it's supposed to do, so we're left with value (em) manipulation instead.  // Opera (9.5x) is even more annoying. Neither "bottom" nor "baseline" does what it's supposed to do, so we're left with value (em) manipulation instead.
  else if(browser=="opera") { rubyrule.style.verticalAlign = "1.3em"; }  else if(browser=="opera") { rubyrule.style.verticalAlign = "1.3em"; }
 +
  // if we don't know what browser this is, assume "bottom" works. If it doesn't, their fault.  // if we don't know what browser this is, assume "bottom" works. If it doesn't, their fault.
  else { rubyrule.style.verticalAlign = "bottom"; }  else { rubyrule.style.verticalAlign = "bottom"; }
Line 226: Line 244:
  
  
-// -------------+// ----------------------------------------------------------------------------------------------------------------------
 // DokuWiki code // DokuWiki code
-// -------------+// ----------------------------------------------------------------------------------------------------------------------
  
 /** /**
- * lets DokuWiki schedule the JavaScript call+ * lets dokuwiki schedule the javascript call
  */  */
 addInitEvent(function(){ fixRubyAlignment(); }); addInitEvent(function(){ fixRubyAlignment(); });
Line 280: Line 298:
  * Postprocesses the HTML that was built from that, to rubify kanji that have associated furigana.  * Postprocesses the HTML that was built from that, to rubify kanji that have associated furigana.
  */  */
- function register(&$controller) + function register(Doku_Event_Handler $controller) 
  {  {
  // initialise variables  // initialise variables
plugin/xhtmlruby.txt · Last modified: 2018-05-31 00:40 by Klap-in