How to use the refextract.references.regexs.get_reference_section_title_patterns function in refextract

To help you get started, we’ve selected a few refextract examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inspirehep / refextract / tests / test_regexs.py View on Github external
def test_reference_section_title_pattern():
    r = regexs.get_reference_section_title_patterns()
    assert len(r) > 2
github inspirehep / refextract / refextract / references / find.py View on Github external
{ 'start_line' : (integer) - index in docbody of 1st reference line,
          'title_string' : (string) - title of the reference section.
          'marker' : (string) - the marker of the first reference line,
          'marker_pattern' : (string) - regexp string used to find the marker,
          'title_marker_same_line' : (integer) - flag to indicate whether the
                                        reference section title was on the same
                                        line as the first reference line's
                                        marker or not. 1 if it was; 0 if not.
        }
        Much of this information is used by later functions to rebuild
        a reference section.
         -- OR --
                (None) - when the reference section could not be found.
    """
    ref_details = None
    title_patterns = get_reference_section_title_patterns()

    # Try to find refs section title:
    for title_pattern in title_patterns:
        # Look for title pattern in docbody
        for reversed_index, line in enumerate(reversed(docbody)):
            title_match = title_pattern.match(line)
            if title_match:
                title = title_match.group('title')
                index = len(docbody) - 1 - reversed_index
                temp_ref_details, found_title = find_numeration(docbody[index:index + 6], title)
                if temp_ref_details:
                    if ref_details and 'title' in ref_details and ref_details['title'] and not temp_ref_details['title']:
                        continue
                    if ref_details and 'marker' in ref_details and ref_details['marker'] and not temp_ref_details['marker']:
                        continue