Skip to content

Commit

Permalink
extract code, text as list
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillarAnand committed Nov 24, 2014
1 parent 413b238 commit 61b933c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 8 additions & 6 deletions nidaba/core/objects.py
@@ -1,6 +1,4 @@
from pyparsing import makeHTMLTags, SkipTo

from .parser import strip_tags
from bs4 import BeautifulSoup


class Base(object):
Expand Down Expand Up @@ -72,9 +70,13 @@ def __init__(self, data, answers=None, comments=None):

@classmethod
def _get_code(cls, html):
code_start, code_end = makeHTMLTags('code')
code = code_start + SkipTo(code_end).setResultsName('body') + code_end
return [token.body for token, start, end in code.scanString(html)]
return [i.get_text() for i in BeautifulSoup(html).find_all('code')]

@classmethod
def _get_text(cls, html):
soup = BeautifulSoup(html)
[s.extract() for s in soup('code')]
return soup.get_text()


class User(object):
Expand Down
4 changes: 0 additions & 4 deletions nidaba/core/parser.py

This file was deleted.

0 comments on commit 61b933c

Please sign in to comment.