Skip to content

Commit

Permalink
correct additional line in ##; correct fallback for ####; normalising…
Browse files Browse the repository at this point in the history
… code space in all
  • Loading branch information
tbates committed Aug 7, 2012
1 parent 6e64693 commit 6b82a62
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Commands/Heading 1 (#).tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// nb: Overrides existing cmd-n
// Also Works on lines that already have a heading applied
$level = '#';
$level = '#';
$newLevel = str_repeat($level, 1); // Change this to alter the level being affected
$o = array();
Expand All @@ -36,12 +36,12 @@ if (0) {
$aLines = explode("\n", $existing);
$l = count($aLines);
foreach ($aLines as $key => $line) {
$line = trim ( $line);
$line = trim ($line);
if (empty($line)) {
if ($l>1) {
$o[] = "";
}else{
$o[] = "$level \${1:Level 1 heading}";
$o[] = "$newLevel \${1:Heading}";
}
} else {
$new = trim ( $line, "#* $level" ); //trim ends of existing markers
Expand Down Expand Up @@ -74,6 +74,6 @@ echo implode("\n", $o);
<key>uuid</key>
<string>5BB3CEFD-D327-4621-B221-54F674560D5E</string>
<key>version</key>
<string>2</string>
<integer>2</integer>
</dict>
</plist>
6 changes: 2 additions & 4 deletions Commands/Heading 2 (# style).tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env php
&lt;?php
// Turn a line or selection into a heading
// Created: 21.03.12 Author: timothy.c.bates@gmail.com
Expand Down Expand Up @@ -34,7 +33,7 @@ if (0) {
$aLines = explode("\n", $existing);
$l = count($aLines);
foreach ($aLines as $key =&gt; $line) {
$line = trim ( $line);
$line = trim ($line);
if (empty($line)) {
if ($l&gt;1) {
$o[] = "";
Expand All @@ -47,8 +46,7 @@ foreach ($aLines as $key =&gt; $line) {
}
}
echo implode("\n", $o);
?&gt;
</string>
?&gt;</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
Expand Down
4 changes: 2 additions & 2 deletions Commands/Heading 3 (# style).tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (0) {
$aLines = explode("\n", $existing);
$l = count($aLines);
foreach ($aLines as $key =&gt; $line) {
$line = trim ( $line);
$line = trim ($line);
if (empty($line)) {
if ($l&gt;1) {
$o[] = "";
Expand Down Expand Up @@ -65,7 +65,7 @@ echo implode("\n", $o);
<key>outputLocation</key>
<string>replaceInput</string>
<key>scope</key>
<string>text.html.markdown</string>
<string>text.html.markdown -meta.disable-markdown</string>
<key>tabTrigger</key>
<string>#</string>
<key>uuid</key>
Expand Down
6 changes: 4 additions & 2 deletions Commands/Heading 4 (# style).tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (0) {
$aLines = explode("\n", $existing);
$l = count($aLines);
foreach ($aLines as $key =&gt; $line) {
$line = trim ( $line);
$line = trim ($line);
if (empty($line)) {
if ($l&gt;1) {
$o[] = "";
Expand All @@ -48,6 +48,8 @@ foreach ($aLines as $key =&gt; $line) {
echo implode("\n", $o);
?&gt;
</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
Expand All @@ -63,7 +65,7 @@ echo implode("\n", $o);
<key>outputLocation</key>
<string>replaceInput</string>
<key>scope</key>
<string>text.html.markdown</string>
<string>text.html.markdown -meta.disable-markdown</string>
<key>tabTrigger</key>
<string>#</string>
<key>uuid</key>
Expand Down

1 comment on commit 6b82a62

@tbates
Copy link
Owner Author

@tbates tbates commented on 6b82a62 Aug 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correcting minor buglets in the heading code: this fixes stuff that is already in there.

Please sign in to comment.