66 lines
2.8 KiB
C#
66 lines
2.8 KiB
C#
#region License
|
|
/*
|
|
MIT License
|
|
|
|
Copyright(c) 2020 Petteri Kautonen
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
#endregion
|
|
|
|
using ScintillaNET;
|
|
using VPKSoft.ScintillaLexers.HelperClasses;
|
|
using VPKSoft.ScintillaLexers.LexerColors;
|
|
using static VPKSoft.ScintillaLexers.LexerEnumerations;
|
|
|
|
namespace VPKSoft.ScintillaLexers.CreateSpecificLexer
|
|
{
|
|
/// <summary>
|
|
/// A class for the HTML lexer.
|
|
/// Implements the <see cref="VPKSoft.ScintillaLexers.CreateSpecificLexer.CreateLexerCommon" />
|
|
/// </summary>
|
|
/// <seealso cref="VPKSoft.ScintillaLexers.CreateSpecificLexer.CreateLexerCommon" />
|
|
class CreateLexerHtml: CreateLexerCommon
|
|
{
|
|
/// <summary>
|
|
/// Creates the lexer for a given Scintilla class instance for the HTML (Hypertext Markup Language).
|
|
/// </summary>
|
|
/// <param name="scintilla">A Scintilla class instance to set the lexer style for.</param>
|
|
/// <param name="lexerColors">A <see cref="LexerColors"/> class instance for the lexer coloring.</param>
|
|
/// <returns>True if the operation was successful; otherwise false.</returns>
|
|
public static bool CreateHtmlLexer(Scintilla scintilla, LexerColors.LexerColors lexerColors, bool foldOn = true)
|
|
{
|
|
// HTML should be simple but the embedded scripts make it hard for lexical "analysis"..
|
|
ClearStyle(scintilla);
|
|
|
|
//..therefore the weird logic.. (which might malfunction)..
|
|
SetHtmlStyles(scintilla, lexerColors);
|
|
SetPhpStyles(scintilla, lexerColors);
|
|
scintilla.LexerName = "hypertext";
|
|
|
|
ScintillaKeyWords.SetKeywords(scintilla, LexerType.HTML);
|
|
|
|
SetScriptedHtml(LexerType.HTML, scintilla, lexerColors);
|
|
if (foldOn)
|
|
AddFolding(scintilla);
|
|
return true;
|
|
}
|
|
}
|
|
}
|