Пример #1
0
        /// <summary>
        /// Gets the HTML for a single sense, not including enclosing paragraph etc., only inline markup.
        /// </summary>
        /// <param name="tprov">Text provider if meta-labels (e.g. "Classifier") are to be included. If null, they are stripped.</param>
        private static string getSenseHtmlPure(ITextProvider tprov, CedictSense sense, SearchScript script)
        {
            StringBuilder sb = new StringBuilder();

            string strDomain = HybridToHtml(sense.Domain, script);
            string strEquiv = HybridToHtml(sense.Equiv, script);
            string strNote = HybridToHtml(sense.Note, script);
            if (sense.Domain != HybridText.Empty)
            {
                if (sense.Domain.EqualsPlainText("CL:"))
                {
                    if (tprov != null)
                    {
                        sb.Append(templateItalicsOpen);
                        sb.Append(escape(tprov.GetString("ResultCtrlClassifier")) + " ");
                        sb.Append(templateItalicsClose);
                    }
                }
                else
                {
                    sb.Append(templateItalicsOpen);
                    sb.Append(strDomain);
                    sb.Append(templateItalicsClose);
                }
            }
            if (sense.Domain != HybridText.Empty && !sense.Domain.EqualsPlainText("CL:"))
                if (sense.Equiv != HybridText.Empty || sense.Note != HybridText.Empty)
                    sb.Append(' ');
            sb.Append(strEquiv);
            if (sense.Equiv != HybridText.Empty && sense.Note != HybridText.Empty)
                sb.Append(' ');
            if (sense.Note != HybridText.Empty)
            {
                sb.Append(templateItalicsOpen);
                sb.Append(strNote);
                sb.Append(templateItalicsClose);
            }

            // Done
            return sb.ToString();
        }
Пример #2
0
        /// <summary>
        /// Gets the sense formatted in HTML.
        /// </summary>
        public static string GetSenseHtml(CedictSense sense, SearchScript script)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(templateOuter);
            string htmlSense = templateSense.Replace("{sense}", getSenseHtmlPure(null, sense, script));
            htmlSense = templateSenseSingleOpen + htmlSense + templateSenseSingleClose;
            sb.Replace("{body}", htmlSense);
            return sb.ToString();
        }