Tutorials to .com

Tutorials to .com » Asp » Skills » ASP website for their own system to build a set of markup language

ASP website for their own system to build a set of markup language

Print View , by: iSee ,Total views: 11 ,Word Count: 1416 ,Date: Sat, 22 Aug 2009 Time: 4:07 AM

As a dynamic Web site during the construction will inevitably encounter the problem of online editing articles. HTML provides a textarea tag, but not actually solve this problem, because the plain text textarea. Unless the input when using the HTML tag, otherwise the output will be from start to finish when there is no structure of a text. WEB design through to build a class of dhtml online WYSIWYG editor has been very good on this issue resolved.

However, WYSIWYG is not the only solution. The author found in a number of Internet portal is the online editor characteristics. It is not WYSIWYG (but provides a preview function), but the text of a textarea field, but does not support the HTML markup language. But has its own set of markup language.


Figure 1

Figure 2

I find it very smooth to use to sum up its merits as follows:

First, it marks not many compared with the HTML is very simple and can be automatically generated through the paragraphs of return can be easily accepted by users. I believe that if the use of Chinese markings, may be more acceptable to domestic users.

Second, the relative WYSIWYG editor the user a better grasp of their own in terms of article structure, and generate less garbage.

Third, the phase can be seen in terms of the HTML is much better, and better after the preview.

Fourth, as a result of their own markup language does not support script, so it is more secure.

After some thinking and practice of the author, is to build such a markup language of their own way to public:

First of all, our own website a simple and necessary to determine the markup language. To determine when to omit unnecessary. Take me, I have determined for their own markup language web site as follows:

[Image] image URL [/ image]
[Headlines] text [/ headline]
[Subhead] text [/ subtitle] (taking into account the user may be broken down so add)
[Bold] text [/ bold]
[Italic] text [/ italic]
[Link] website [/ link]

Then, to provide a mechanism for the browser to read our tags. So, allow your browser to understand how we have set ourselves this tag? Showed the page in the content, we need to write a program to all of our translated into standard markers the HTML tags, but must be filtered after the user lose the HTML code entered.

The first step: filtering HTML code.

This is actually very simple, as long as all the "<" label replaced with "<", while all the ">" replaced by ">" on it. In the asp in the achievement of the adoption of the following statements:

Content = replace (content ,"<","<")

Content = replace (content ,">",">")

(The above code, content is stored in the content we want to show the variables, if there is also below that mean the same.)

Step two: we are translated into HTML markup

This relatively complex, not simply because of all [labels replace <and] replaced by> and then inside the Chinese (such as pictures) translated into English (such as IMG) is fine. There are two reasons:

1 is the content inside the tag, according to the classification of different treatment needs to be done:

First, the direct display to the user, such as:

[Headlines] text [/ headline]

At this point as long as the label is translated into the corresponding English, such as the tag above <h1> text translated into </ h1> it.

The second category does not directly presented to the user, such as:

[Image] Image URL [/ image]

At this time, the contents of the middle tab "Image URL" is only part of our Web site to display in HTML in <IMG> labels as SRC attribute, and the label is not the end of HTML tags. Therefore, the results of the direct translation is in the affirmative wrong.

The third category, while at the same time directly as a property, such as:

[Link] website [/ link]

2 is not all out of place markers are to be translated, for example, users sometimes need to use symbols "[" and the symbol "]" to the performance of their content, and this time will do the tag if translated as "<" and ">" is certainly not in line with the user's liking.

Analysis of the problems, I will be prepared following the procedure given the idea of reference and a reference procedure.

Different labels as a result of the translation needs of different ways, it is necessary for different labels, one of the translation.

For any single marker, an article may appear in more than this may not occur again, the program should first check from start to finish marking the beginning of a tag (such as the "picture] picture address [/ image]" Yes " [image] ") appear, once the check arrived, and then check the location of the beginning of the end marker, if checked to, then we have to say that it is the mark; if the end tag did not check to, then it is not that we want tag, but only display the user's own content. After checking to be translated into HTML markup tags, and marked in accordance with different types of content be treated differently. Sitting After marking the location from the end and continue to check until the end of the article.

The actual preparation, it is necessary to use the idea of recursion. The following is the translation [picture] picture address [/ image] This marked an example of the procedure.

Function TranslateImg (Str)
Start = instr (str, "[Image]") 'check marked the beginning of the location If start = 0 then exit function' to start position to 0, that there is no such tag, then the end of the process End = instr (start, str, "[/ picture] " 'check the following locations by the beginning of the end of marking the location of emerging If end = 0 then exit function' end tag occurrence is 0, that there is no end tag, the end of the process MidStr = mid (str, start +4, end - start-4) 'the contents of the middle marker ReplaceStr = mid (str, start, end-start +5)' marking the contents of the middle marking, as the content will be replaced Str = replace (instr, ReplaceStr, "<img src = "& MidStr &">") 'will be translated into HTML tags
TranslateImg Str 'implementation of the recursive function
End Function

From the above analysis, I believe the reader through an analysis of their own site to build a "MyHTML" markup language for the.

In the actual development of a number of issues will need to overcome, such as: the handling of nested tags; was submitted to the user database or to be translated before the users to browse articles from the database when transferred out of the translation; to provide users with a number of automatic Insert tag button operation and user-friendly experience of Gordon. This article used only puts a little hope that attracted readers to enjoy.


ASP skills Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.