Improved handling of header anchors whose main content starts/ends with a space.

This commit is contained in:
Dario Solera 2009-12-14 18:07:56 +00:00
parent 5b4f5e3df5
commit 5a396a5ae0
2 changed files with 6 additions and 2 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.1.441")] [assembly: AssemblyVersion("3.0.1.442")]
[assembly: AssemblyFileVersion("3.0.1.441")] [assembly: AssemblyFileVersion("3.0.1.442")]

View file

@ -2078,6 +2078,10 @@ namespace ScrewTurn.Wiki {
/// <param name="h">The string, usually a header (Hx).</param> /// <param name="h">The string, usually a header (Hx).</param>
/// <returns>The anchor ID.</returns> /// <returns>The anchor ID.</returns>
public static string BuildHAnchor(string h) { public static string BuildHAnchor(string h) {
// Remove any extra spaces around the heading title:
// '=== Title ===' results in '<a id="Title">' instead of '<a id="_Title_">'
if(h != null) h = h.Trim();
StringBuilder sb = new StringBuilder(StripWikiMarkup(h)); StringBuilder sb = new StringBuilder(StripWikiMarkup(h));
sb.Replace(" ", "_"); sb.Replace(" ", "_");
sb.Replace(".", ""); sb.Replace(".", "");