Ticket #160 (new enhancement)

Opened 8 years ago

Last modified 7 years ago

Formatter for Superscript / Subscript

Reported by: NilsLindenberg Owned by: unassigned
Priority: low Milestone: 2.0
Component: formatters Version: 1.1.6.1
Severity: minor Keywords: superscript subscript formatter
Cc:

Description (last modified by JavaWoman) (diff)

Superscript and subscript (<sup>/<sub>)

(text higher or lower in the line than normal)

There are only simple changes needed to add wikka-formatters for superscript and subscript text; the bigger problem is the markup:

Nils:

  • for superscript: ^^
  • for subscript: vv (would be logical, but perhaps problematic?)

BlueNode: /\superscript/\ (forwardslash,backslash) \/subscript\/ (backslash,forwardslash)

Javawoman: Or what about two commas ,, for subscript?

Code Changes

Anyway, changes necessary to formatters/wakka.php: add to the list of static variables (after trigger_center = 0;)

        static $trigger_sup = 0;
        static $trigger_sub = 0;

add after if ($trigger_bold % 2) echo('</strong>');

            if ($trigger_sup % 2) echo '</sup>';
            if ($trigger_sub % 2) echo '</sub>';

change the long line a little below to:

            $trigger_bold = $trigger_center = $trigger_floatl = $trigger_inserted = $trigger_deleted = $trigger_italic = $trigger_keys = $trigger_sup = $trigger_sub = 0;

add after the //center block:

        // higher text
        else if ($thing == " ") // enter the markup 
        {
            return (++$trigger_sup % 2 ? "<sup>" : "</sup>");
        }
        // lowered text
        else if ($thing == "  ") // enter the markup 
        {
            return (++$trigger_sub % 2 ? "<sub>" : "</sub>");
        }

and finally the line with #Wiki Markup (near the end) needs to have the markup, too: (example with ^^ and vv)

"\*\*|\'\'|\#\#|\#\%|@@|::c::|\>\>|\<\<|&pound;&pound;|&yen;&yen;|\v\v|\^\^|\+\+|__|<|>|\/\/|".    # Wiki markup

Ref:  http://wikkawiki.org/WantedFormatters

Change History

Changed 7 years ago by BrianKoontz

  • milestone set to 1.2

Bumped to milestone 1.2 for further discussion.

Changed 7 years ago by ydario

Other wiki are using

^^ for superscript and ,, for subscript

e.g. see trac wiki or uniwakka. It will be nice to have same coding syntax (just to not get crazy while using different wikis).

Changed 7 years ago by ydario

This patch is against 1.1.6.3 source code, uses above tags for generating super/subscripts.

diff -urbB wiki.0/formatters/wakka.php wiki/formatters/wakka.php
--- wiki.0/formatters/wakka.php	Mon May  7 02:21:52 2007
+++ wiki/formatters/wakka.php	Mon Jun  4 17:50:54 2007
@@ -60,6 +60,8 @@
 		static $trigger_strike = 0;
 		static $trigger_inserted = 0;
 		static $trigger_center = 0;
+		static $trigger_subscript = 0;
+		static $trigger_superscript = 0;
 		static $trigger_l = array(-1, 0, 0, 0, 0, 0);
 		static $output = '';
 		static $valid_filename = '';
@@ -120,6 +122,16 @@
 		{
 			return (++$trigger_italic % 2 ? "<em>" : "</em>");
 		}
+		// subscript
+		else if ($thing == ",,")
+		{
+			return (++$trigger_subscript % 2 ? "<sub>" : "</sub>");
+		}
+		// superscript
+		else if ($thing == "^^")
+		{
+			return (++$trigger_superscript % 2 ? "<sup>" : "</sup>");
+		}
 		// underlinue
 		else if ($thing == "__")
 		{
@@ -435,6 +472,7 @@
 	"-{4,}|---|".																			# separator (hr)
 	"\b[a-z]+:\/\/\S+|".																	# URL
 	"\*\*|\'\'|\#\#|\#\%|@@|::c::|\>\>|\<\<|&pound;&pound;|&yen;&yen;|\+\+|__|<|>|\/\/|".	# Wiki markup
+	"\^\^|,,|".
 	"======|=====|====|===|==|".															# headings
 	"\n([\t~]+)(-|&|[0-9a-zA-Z]+\))?|".														# indents and lists
 	"\{\{.*?\}\}|".																			# action

Changed 7 years ago by JavaWoman

  • description modified (diff)

changing description to make intended code samples visible ;)

Changed 7 years ago by JavaWoman

  • description modified (diff)
Note: See TracTickets for help on using tickets.