Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ed6bc87f89
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (70 sloc) 2.189 kb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env php
&lt;?php
// Turn a line or selection into a heading
// Created: 23.12.08 Author: timothy.c.bates@gmail.com
// nb: Overrides existing cmd-n
// Also Works on multiple lines and lines that already have a heading applied
$level = '=';
$thisNum = 5;
$newLevel = str_repeat ( $level, $thisNum); // Change this to alter the level being affected
$o = array();
if (0) { //set to 1 for debugging
echo "&lt;pre&gt;";
$existing = "$level$level$level Why is is this so badly formed? $level$level$level";
$existing = "$level$level$level Why is is this so badly formed? $level$level$level
$level$level$level Why is is this so badly formed? $level$level$level
$level$level$level Why is is this so badly formed? $level$level$level";
// $existing = ""; // test case of empty line
echo "started with:\n&lt;font color=red&gt;\"$existing\"&lt;/font&gt;\n--&gt;\n";
} else {
$existing = fread(STDIN, 1024);
}
$aLines = explode("\n", $existing);
$l = count($aLines);
foreach ($aLines as $key =&gt; $line) {
$line = trim ( $line);
if (empty($line)) {
if ($l&gt;1) {
$o[] = "";
}else{
$o[] = "$newLevel \${1:Level $thisNum heading} $newLevel";
}
} else {
$new = trim ( $line, " $level" ); //trim existing markers from either end
$o[] = "$newLevel $new $newLevel";
}
}
echo implode("\n", $o);
?&gt;
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>@5</string>
<key>name</key>
<string>h5</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>snippet</string>
<key>outputLocation</key>
<string>replaceInput</string>
<key>scope</key>
<string>text.html.mediawiki</string>
<key>uuid</key>
<string>184223B3-EBEF-4172-B7A8-EA53FEDE2996</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
Jump to Line
Something went wrong with that request. Please try again.