Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra <p> tags appear in results snippet #72

Closed
gamov opened this issue Feb 26, 2014 · 1 comment
Closed

Extra <p> tags appear in results snippet #72

gamov opened this issue Feb 26, 2014 · 1 comment

Comments

@gamov
Copy link
Contributor

gamov commented Feb 26, 2014

Extracted from a search index created by rdoc (4.1.1)

["assert_equal",
   ...
   "<p>Tests if <code>expected</code> is equal to <code>actual</code>.\n<p>An optional failure message may be provided as the final argument. …\n",
null,0]

Those extra p tags appear in the search results (they wouldn't in the past). I tried to look into rdoc why but that gem is quite intricate. The source lines that appear for snippet are treated as RDoc::Markup::Paragraph, I think that's why rdoc add those p tag.
I don't have enough knowledge to fix the source of the problem, but I have a workaround:
In searchdoc.js, change this line (in renderItem):

if (result.snippet) html += '<p class="snippet">' + escapeHTML(result.snippet) + '</p>';

to

if (result.snippet) html += '<p class="snippet">' + result.snippet.split('\n')[0].replace('<p>','') + '</p>';

I actually prefer this since the original line escapes the html making presentation tags apparent in the result...

PS: Why aren't those p tags closed by rdoc?
PS2: http://api.rubyonrails.org is also currently showing the bug

@sunaku
Copy link
Contributor

sunaku commented Jul 12, 2014

Hi @gamov, I created a pull request containing your patch in issue #77.

sunaku pushed a commit to sunaku/sdoc that referenced this issue Jul 12, 2014
zzak pushed a commit that referenced this issue Aug 11, 2014
GH-72: Extra <p> tags appear in results snippet
@zzak zzak closed this as completed Aug 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants