├── .gitignore
├── LICENSE.txt
├── Less.Html.sln
├── Less.Html
├── CssInternal
│ ├── Context.cs
│ ├── PropertyReader.cs
│ ├── ReaderBase.cs
│ └── SelectorReader.cs
├── CssParser.cs
├── HtmlInternal
│ ├── AttributeReader.cs
│ ├── CloseScriptReader.cs
│ ├── CloseStyleReader.cs
│ ├── Context.cs
│ ├── EndingReader.cs
│ ├── ReaderBase.cs
│ ├── TagMark.cs
│ └── TagReader.cs
├── HtmlParser.cs
├── Less.Html.csproj
├── Less.Html.nuspec
├── Nodes
│ ├── Attr.cs
│ ├── Comment.cs
│ ├── Document
│ │ ├── Document.cs
│ │ └── DocumentContent.cs
│ ├── Element
│ │ ├── Element.cs
│ │ └── Indexes
│ │ │ ├── IndexBase.cs
│ │ │ ├── IndexOnClass.cs
│ │ │ ├── IndexOnId.cs
│ │ │ ├── IndexOnName.cs
│ │ │ └── IndexOnTagName.cs
│ ├── ElementCollection.cs
│ ├── NamedNodeMap.cs
│ ├── Node.cs
│ ├── SelfCheckingException.cs
│ └── Text.cs
├── Properties
│ └── AssemblyInfo.cs
├── Query
│ ├── ElementExtensions.cs
│ ├── NodeExtensions.cs
│ ├── Query.cs
│ ├── QueryExtensions.cs
│ ├── Selector.cs
│ └── SelectorParam.cs
├── SelectorParser
│ ├── AttrSelectorReader.cs
│ ├── Context.cs
│ ├── ElementFilter.cs
│ ├── Filters
│ │ ├── FilterByAll.cs
│ │ ├── FilterByAttr.cs
│ │ ├── FilterByClass.cs
│ │ ├── FilterById.cs
│ │ ├── FilterByOther.cs
│ │ └── FilterByTagName.cs
│ ├── ParamParser.cs
│ ├── ReaderBase.cs
│ ├── SelectorParamException.cs
│ └── SelectorReader.cs
├── StyleParser.cs
├── Styles
│ ├── Block.cs
│ ├── BlockCollection.cs
│ ├── Css.cs
│ ├── CssInfo.cs
│ ├── Properties
│ │ ├── Background.cs
│ │ ├── BackgroundImage.cs
│ │ └── Src
│ │ │ ├── Src.cs
│ │ │ ├── SrcValue.cs
│ │ │ └── SrcValueCollection.cs
│ ├── Property.cs
│ ├── PropertyCollection.cs
│ ├── Style.cs
│ └── StyleCollection.cs
└── packages.config
├── README.md
├── Test
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Test.csproj
├── Test1.cs
├── Test2.cs
├── Test3.cs
├── Test4.cs
├── Test5.cs
├── Test6.cs
├── packages.config
├── testCss
│ ├── app.cb1b40f2.css
│ ├── bibaoke.com.css
│ └── haidilao.com.css
└── testHtml
│ ├── 265.com.html
│ ├── auto.qq.com.html
│ ├── avon.co.za.error.html
│ ├── avon.co.za.html
│ ├── js.html
│ ├── kayak.com.html
│ ├── killedbypolice.net.html
│ ├── lrcmyanmar.org.html
│ ├── tsite.jp.html
│ ├── wsbuluo.com.html
│ ├── www.darc.de.html
│ └── youpinai.com.html
└── Test4
├── App.config
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── Test4.csproj
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | [Ss]tyle[Cc]op.*
182 | ~$*
183 | *~
184 | *.dbmdl
185 | *.dbproj.schemaview
186 | *.pfx
187 | *.publishsettings
188 | node_modules/
189 | orleans.codegen.cs
190 |
191 | # RIA/Silverlight projects
192 | Generated_Code/
193 |
194 | # Backup & report files from converting an old project file
195 | # to a newer Visual Studio version. Backup files are not needed,
196 | # because we have git ;-)
197 | _UpgradeReport_Files/
198 | Backup*/
199 | UpgradeLog*.XML
200 | UpgradeLog*.htm
201 |
202 | # SQL Server files
203 | *.mdf
204 | *.ldf
205 |
206 | # Business Intelligence projects
207 | *.rdl.data
208 | *.bim.layout
209 | *.bim_*.settings
210 |
211 | # Microsoft Fakes
212 | FakesAssemblies/
213 |
214 | # GhostDoc plugin setting file
215 | *.GhostDoc.xml
216 |
217 | # Node.js Tools for Visual Studio
218 | .ntvs_analysis.dat
219 |
220 | # Visual Studio 6 build log
221 | *.plg
222 |
223 | # Visual Studio 6 workspace options file
224 | *.opt
225 |
226 | # Visual Studio LightSwitch build output
227 | **/*.HTMLClient/GeneratedArtifacts
228 | **/*.DesktopClient/GeneratedArtifacts
229 | **/*.DesktopClient/ModelManifest.xml
230 | **/*.Server/GeneratedArtifacts
231 | **/*.Server/ModelManifest.xml
232 | _Pvt_Extensions
233 |
234 | # LightSwitch generated files
235 | GeneratedArtifacts/
236 | ModelManifest.xml
237 |
238 | # Paket dependency manager
239 | .paket/paket.exe
240 |
241 | # FAKE - F# Make
242 | .fake/
243 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [2017] [Shao Zhuang]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Less.Html.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Less.Html", "Less.Html\Less.Html.csproj", "{5749EA1F-89F8-4029-96BE-457170DE431A}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{1C0BBB42-D921-4AC3-8A05-754E9553280D}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test4", "Test4\Test4.csproj", "{8A44E7D7-9117-4284-BFFA-C2BFE3BA4769}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {5749EA1F-89F8-4029-96BE-457170DE431A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {5749EA1F-89F8-4029-96BE-457170DE431A}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {5749EA1F-89F8-4029-96BE-457170DE431A}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {5749EA1F-89F8-4029-96BE-457170DE431A}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {1C0BBB42-D921-4AC3-8A05-754E9553280D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {1C0BBB42-D921-4AC3-8A05-754E9553280D}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {1C0BBB42-D921-4AC3-8A05-754E9553280D}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {1C0BBB42-D921-4AC3-8A05-754E9553280D}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {8A44E7D7-9117-4284-BFFA-C2BFE3BA4769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {8A44E7D7-9117-4284-BFFA-C2BFE3BA4769}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {8A44E7D7-9117-4284-BFFA-C2BFE3BA4769}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {8A44E7D7-9117-4284-BFFA-C2BFE3BA4769}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/Less.Html/CssInternal/Context.cs:
--------------------------------------------------------------------------------
1 | //bibaoke.com
2 |
3 | namespace Less.Html.CssInternal
4 | {
5 | internal class Context
6 | {
7 | internal Css Css
8 | {
9 | get;
10 | private set;
11 | }
12 |
13 | internal int Position
14 | {
15 | get;
16 | set;
17 | }
18 |
19 | internal Style CurrentStyle
20 | {
21 | get;
22 | set;
23 | }
24 |
25 | internal Block CurrentBlock
26 | {
27 | get;
28 | set;
29 | }
30 |
31 | internal Context(string content)
32 | {
33 | this.Css = new Css(content);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Less.Html/CssInternal/PropertyReader.cs:
--------------------------------------------------------------------------------
1 | //bibaoke.com
2 |
3 | using Less.Text;
4 | using System.Text.RegularExpressions;
5 |
6 | namespace Less.Html.CssInternal
7 | {
8 | internal class PropertyReader : ReaderBase
9 | {
10 | private static Regex Pattern
11 | {
12 | get;
13 | set;
14 | }
15 |
16 | private static Regex NameValuePattern
17 | {
18 | get;
19 | set;
20 | }
21 |
22 | static PropertyReader()
23 | {
24 | PropertyReader.Pattern = @"
25 | (\s*(?/\*.*?\*/))|
26 | (\s*(?.*?)\s*(?;|}))".ToRegex(
27 | RegexOptions.IgnorePatternWhitespace |
28 | RegexOptions.Singleline |
29 | RegexOptions.Compiled |
30 | RegexOptions.ExplicitCapture);
31 |
32 | PropertyReader.NameValuePattern = @"(?[\w-]+)\s*:\s*(?.+)\s*".ToRegex(
33 | RegexOptions.Singleline |
34 | RegexOptions.Compiled |
35 | RegexOptions.ExplicitCapture);
36 | }
37 |
38 | internal override ReaderBase Read()
39 | {
40 | Match match = PropertyReader.Pattern.Match(this.Content, this.Position);
41 |
42 | if (match.Success)
43 | {
44 | this.Ascend(match);
45 |
46 | Group comment = match.Groups["comment"];
47 |
48 | if (comment.Success)
49 | {
50 | return this.Pass();
51 | }
52 | else
53 | {
54 | Group property = match.Groups["property"];
55 | Group ending = match.Groups["ending"];
56 |
57 | Match matchNameValue = PropertyReader.NameValuePattern.Match(property.Value);
58 |
59 | if (matchNameValue.Success)
60 | {
61 | Group name = matchNameValue.Groups["name"];
62 | Group value = matchNameValue.Groups["value"];
63 |
64 | int valueBegin = property.Index + value.Index;
65 |
66 | Property p = new Property(this.Css,
67 | property.Index,
68 | property.Index + name.Length - 1,
69 | valueBegin,
70 | valueBegin + value.Length - 1,
71 | property.Index + property.Length - 1);
72 |
73 | this.CurrentStyle.Add(p);
74 | }
75 |
76 | if (ending.Value == ";")
77 | {
78 | return this.Pass();
79 | }
80 | else
81 | {
82 | this.CurrentStyle.End = ending.Index;
83 |
84 | if (this.CurrentBlock.IsNull())
85 | {
86 | this.Styles.Add(this.CurrentStyle);
87 | }
88 | else
89 | {
90 | this.CurrentBlock.Styles.Add(this.CurrentStyle);
91 | }
92 |
93 | return this.Pass();
94 | }
95 | }
96 | }
97 | else
98 | {
99 | return null;
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/Less.Html/CssInternal/ReaderBase.cs:
--------------------------------------------------------------------------------
1 | //bibaoke.com
2 |
3 | using System.Text.RegularExpressions;
4 |
5 | namespace Less.Html.CssInternal
6 | {
7 | internal abstract class ReaderBase
8 | {
9 | internal Context Context
10 | {
11 | get;
12 | set;
13 | }
14 |
15 | internal Css Css
16 | {
17 | get
18 | {
19 | return this.Context.Css;
20 | }
21 | }
22 |
23 | internal string Content
24 | {
25 | get
26 | {
27 | return this.Css.Content;
28 | }
29 | }
30 |
31 | internal int Position
32 | {
33 | get
34 | {
35 | return this.Context.Position;
36 | }
37 | set
38 | {
39 | this.Context.Position = value;
40 | }
41 | }
42 |
43 | internal Style CurrentStyle
44 | {
45 | get
46 | {
47 | return this.Context.CurrentStyle;
48 | }
49 | set
50 | {
51 | this.Context.CurrentStyle = value;
52 | }
53 | }
54 |
55 | internal Block CurrentBlock
56 | {
57 | get
58 | {
59 | return this.Context.CurrentBlock;
60 | }
61 | set
62 | {
63 | this.Context.CurrentBlock = value;
64 | }
65 | }
66 |
67 | internal StyleCollection Styles
68 | {
69 | get
70 | {
71 | return this.Css.Styles;
72 | }
73 | }
74 |
75 | internal BlockCollection Blocks
76 | {
77 | get
78 | {
79 | return this.Css.Blocks;
80 | }
81 | }
82 |
83 | internal abstract ReaderBase Read();
84 |
85 | protected T Pass() where T : ReaderBase, new()
86 | {
87 | T t = new T();
88 |
89 | t.Context = this.Context;
90 |
91 | return t;
92 | }
93 |
94 | protected void Ascend(Match match)
95 | {
96 | this.Position = match.Index + match.Length;
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/Less.Html/CssInternal/SelectorReader.cs:
--------------------------------------------------------------------------------
1 | //bibaoke.com
2 |
3 | using System.Text.RegularExpressions;
4 | using Less.Text;
5 |
6 | namespace Less.Html.CssInternal
7 | {
8 | internal class SelectorReader : ReaderBase
9 | {
10 | private static Regex Pattern
11 | {
12 | get;
13 | set;
14 | }
15 |
16 | private static Regex CloseBracePattern
17 | {
18 | get;
19 | set;
20 | }
21 |
22 | static SelectorReader()
23 | {
24 | SelectorReader.Pattern = @"
25 | (\s*(?}))|
26 | (\s*/\*(?.*?)\*/)|
27 | (\s*(?@.*?)\s*{)|
28 | (\s*(?.*?)\s*{)".ToRegex(
29 | RegexOptions.IgnorePatternWhitespace |
30 | RegexOptions.Singleline |
31 | RegexOptions.Compiled |
32 | RegexOptions.ExplicitCapture);
33 |
34 | SelectorReader.CloseBracePattern = "}".ToRegex(
35 | RegexOptions.Singleline |
36 | RegexOptions.Compiled);
37 | }
38 |
39 | internal override ReaderBase Read()
40 | {
41 | Match match = SelectorReader.Pattern.Match(this.Content, this.Position);
42 |
43 | if (match.Success)
44 | {
45 | this.Ascend(match);
46 |
47 | Group close = match.Groups["close"];
48 |
49 | if (close.Success)
50 | {
51 | if (this.CurrentBlock.IsNotNull())
52 | {
53 | this.CurrentBlock.End = close.Index;
54 |
55 | this.Blocks.Add(this.CurrentBlock);
56 |
57 | this.CurrentBlock = null;
58 | }
59 |
60 | return this.Pass();
61 | }
62 | else
63 | {
64 | Group comment = match.Groups["comment"];
65 |
66 | if (comment.Success)
67 | {
68 | return this.Pass();
69 | }
70 | else
71 | {
72 | Group at = match.Groups["at"];
73 |
74 | if (at.Success)
75 | {
76 | if (at.Value.IsNotEmpty())
77 | {
78 | string prefix = at.Value.Split('-')[0];
79 |
80 | int endIndex = at.Index + at.Length - 1;
81 |
82 | if (prefix.CompareIgnoreCase("media"))
83 | {
84 | this.CurrentBlock = new Block(this.Css, at.Index, endIndex);
85 |
86 | return this.Pass();
87 | }
88 | else
89 | {
90 | this.CurrentStyle = new Style(this.Css, at.Index, endIndex);
91 |
92 | return this.Pass();
93 | }
94 | }
95 | else
96 | {
97 | return this.Ignore();
98 | }
99 | }
100 | else
101 | {
102 | Group selector = match.Groups["selector"];
103 |
104 | if (selector.Value.IsNotEmpty())
105 | {
106 | this.CurrentStyle = new Style(this.Css, selector.Index, selector.Index + selector.Length - 1);
107 |
108 | return this.Pass();
109 | }
110 | else
111 | {
112 | return this.Ignore();
113 | }
114 | }
115 | }
116 | }
117 | }
118 | else
119 | {
120 | return null;
121 | }
122 | }
123 |
124 | private ReaderBase Ignore()
125 | {
126 | Match matchCloseBrace = SelectorReader.CloseBracePattern.Match(this.Content, this.Position);
127 |
128 | if (matchCloseBrace.Success)
129 | {
130 | this.Ascend(matchCloseBrace);
131 |
132 | return this.Pass();
133 | }
134 | else
135 | {
136 | return null;
137 | }
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/Less.Html/CssParser.cs:
--------------------------------------------------------------------------------
1 | //bibaoke.com
2 |
3 | using Less.Html.CssInternal;
4 |
5 | namespace Less.Html
6 | {
7 | ///
8 | /// css 解析器
9 | ///
10 | public static class CssParser
11 | {
12 | ///
13 | /// 解析
14 | ///
15 | ///
16 | ///
17 | public static Css Parse(string content)
18 | {
19 | ReaderBase reader = new SelectorReader();
20 |
21 | Context context = new Context(content);
22 |
23 | reader.Context = context;
24 |
25 | while (true)
26 | {
27 | reader = reader.Read();
28 |
29 | if (reader.IsNull())
30 | {
31 | break;
32 | }
33 | }
34 |
35 | return context.Css;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Less.Html/HtmlInternal/CloseScriptReader.cs:
--------------------------------------------------------------------------------
1 | //bibaoke.com
2 |
3 | using System.Text.RegularExpressions;
4 | using Less.Text;
5 |
6 | namespace Less.Html.HtmlInternal
7 | {
8 | ///
9 | /// script 闭标签阅读器
10 | ///
11 | internal class CloseScriptReader : ReaderBase
12 | {
13 | ///
14 | /// 正则表达式
15 | ///
16 | private static Regex Pattern
17 | {
18 | get;
19 | set;
20 | }
21 |
22 | ///
23 | /// 初始化
24 | ///
25 | static CloseScriptReader()
26 | {
27 | CloseScriptReader.Pattern = @"
28 | (?