7

Komodo Edit内からHTMLを再フォーマットする、またはTidyに対するプロセスを自動化する簡単な方法はありますか?

CtrlVisual Studioの+ KCtrl+のようなものはD素晴らしいでしょう。私は現在、TidyがインストールされたUbuntuを実行しています。

4

5 に答える 5

8

まっすぐに機能するソリューションが必要な場合は、次の手順を実行します。

  • 右側のツールボックスパネルをポップオープンします。
  • 歯車をクリックして、[新しいマクロ]を選択します。好きな名前を付けてください。

ここでマクロコードを取得します。

コモド編集マクロ(404)

http://jsbeautifier.org/からのコードが含まれており、魅力のように機能します...

次に、キーストロークを設定します。

  • ツールボックスで新しいマクロを選択します

  • 次に、キーバインディングに移動します

    シーケンスを入力すると、入力したシーケンスが使用可能かどうかがわかります。Ctrl+を使用する/のは、それらが互いに近いためです。

于 2012-04-06T22:10:09.610 に答える
7

このフォーマットスクリプト(マクロ)を見つけて、最新のKomodo Edit(v6.1.0)で個人的に使用できるように調整しました。それはうまく機能し、コメンテーターによって提供されたJavaScriptフォーマットを含めましたが、KomodoIDEでのみ機能する可能性があると思います。それは私の目的にとって重要ではありません。

おそらく、そこにいる誰かが( HTML Tidyのようなものを使用して)普遍的な改善を見つけることができます。

komodo.assertMacroVersion(3);
if (komodo.view) { komodo.view.setFocus(); }

var formatter;
var language = komodo.document.language;
switch (language) {
    case 'Perl':
        formatter = 'perltidy -i=2 -pt=2 -l=0';
        break;
    case 'XML':
    case 'XUL':
    case 'XLST':
        formatter = 'tidy -q -xml -i -w 80';
        break;
    case 'HTML':
        formatter = 'tidy -q -asxhtml -i -w 120';
        break;
  //case 'JavaScript':
  //    ko.views.manager.currentView.scimoz.selectAll();
  //    ko.views.manager.currentView.scimoz.replaceSel(js_beautify(ko.views.manager.currentView.scimoz.text, {indent_size: 2}));
  //    return null;
  default:
        alert("I don't know how to tidy " + language);
        return null;
}

// Save current cursor position
var currentPos = komodo.editor.currentPos;

try {
    // Save the file. After the operation you can check what changes where made by
    // File -> Show Unsaved Changes
    komodo.doCommand('cmd_save');

    // Group operations into a single undo
    komodo.editor.beginUndoAction();

    // Select entire buffer and pipe it into formatter.
    komodo.doCommand('cmd_selectAll');
    Run_RunEncodedCommand(window, formatter + " {'insertOutput': True, 'operateOnSelection': True}");

     // Restore cursor. It will be close to the where it started depending on how the text was modified.
     komodo.editor.gotoPos(currentPos);

    // On Windows, when the output of a command is inserted into an edit buffer it has Unix line ends.
    komodo.doCommand('cmd_cleanLineEndings');
}
catch (e) {
    alert(e);
}
finally {
    // Must end undo action or we may corrupt edit buffer
    komodo.editor.endUndoAction();
}
于 2011-02-21T16:30:27.337 に答える
1

選択したHTMLを整頓されたバージョンに置き換えるために実行するコマンドを設定できます。Ctrl+を押しRてコマンドウィンドウを表示し、tidy -utf8 -asxhtml -iUTF-8エンコーディングを使用してインデントされたXHTMLをフォーマットするコマンドを入力します。

「選択を入力として渡す」と「出力を挿入する」の2つのチェックボックスをオンにします。そこでカスタムキーバインディングを指定することもできます。

スクリーンショットの例:http://grab.by/8C3t

于 2011-01-27T09:37:59.390 に答える
1

TAOcodeが行った答えは素晴らしいですが、Komodoの新しいバージョンではいくつかの変更が加えられているため、コードを更新して再び機能させることができます。

komodo.assertMacroVersion(3);
if (komodo.view) { 
    komodo.view.setFocus(); 
}

var formatter;
var language = komodo.view.language;
switch (language) {
    case 'Perl':
        formatter = 'perltidy -i=2 -pt=2 -l=0';
        break;
    case 'XML':
    case 'XUL':
    case 'XLST':
        formatter = 'tidy -q -xml -i -w 500';
        break;
    case 'HTML':
        formatter = 'tidy -q -asxhtml -i -w 120';
        break;
  //case 'JavaScript':
  //    ko.views.manager.currentView.scimoz.selectAll();
  //    ko.views.manager.currentView.scimoz.replaceSel(js_beautify(ko.views.manager.currentView.scimoz.text, {indent_size: 2}));
  //    return null;
  default:
      alert("I don't know how to tidy " + language);
      return null;
}

// Save the current cursor position
var currentPos = komodo.editor.currentPos;

try {
    // Save the file. After the operation you can check what changes where made by
    // File -> Show Unsaved Changes
    komodo.doCommand('cmd_save');

    // Group operations into a single undo
    komodo.editor.beginUndoAction();

    // Select the entire buffer and pipe it into the formatter.
    komodo.doCommand('cmd_selectAll');
    ko.run.runEncodedCommand(window, formatter + " {'insertOutput': True, 'operateOnSelection': True}");

     // Restore the cursor. It will be close to the where it started, depending on how the text was modified.
     komodo.editor.gotoPos(currentPos);

    // On Windows, when the output of a command is inserted into an edit buffer it has Unix line ends.
    komodo.doCommand('cmd_cleanLineEndings');
}
catch (e) {
    alert(e);
}
finally {
    // Must end undo action or may corrupt edit buffer
    komodo.editor.endUndoAction();
}

大きな違いは5行目です:komodo.document.languageはkomodo.view.languageになり、40行目:Run_RunEncodedCommandはko.run.runEncodedCommandになります

于 2016-03-07T22:41:06.843 に答える
0
  1. メニューの[ツールボックス] → [追加] → [新しいコマンド]に移動します

  2. [実行]フィールドにTidyコマンドライン引数を入力します。

     tidy -config tidy_config_html.txt
    
  3. すべてのチェックボックスをオンにします

  4. Start InフィールドにTidyへのパスを入力します

  5. [キーバインド]タブをクリックします

  6. Ctrl+1新しいキーシーケンスとして使用します

  7. Ctrl+ACtrl+を押します1

于 2012-01-05T22:30:10.250 に答える